#!/usr/bin/perl -w

use v5.38;
use List::Util qw(max);

my $sum;
while (<>) {
	$sum += max(/ (\d+) red/g)
		* max(/ (\d+) green/g)
		* max(/ (\d+) blue/g);
}

say $sum;
