#!/usr/bin/perl -w

use v5.16;

chomp (my @mem = split /,/, <>);
$mem[1] = 12;
$mem[2] = 2;
my $pc = 0;
while (1) {
	if ($mem[$pc] == 1) {
		$mem[ $mem[$pc+3] ] = $mem[ $mem[$pc+1] ] + $mem[ $mem[$pc+2] ];
	} elsif ($mem[$pc] == 2) {
		$mem[ $mem[$pc+3] ] = $mem[ $mem[$pc+1] ] * $mem[ $mem[$pc+2] ];
	} elsif ($mem[$pc] == 99) {
		last;
	}
	$pc += 4;
}

say $mem[0];
