#!/usr/bin/perl

use v5.30;
use strict;

my @code = map { chomp; [ split /\s+/ ] } <>;
my %regs;
my $pc = 0;
my $muls;
while ($pc < @code) {
	my ($ins, $a1, $a2) = @{ $code[$pc] };
	my $v1 = $a1 =~ /[a-z]/ ? $regs{$a1} : $a1
		if defined $a1;
	my $v2 = $a2 =~ /[a-z]/ ? $regs{$a2} : $a2
		if defined $a2;
	if ($ins eq 'set') {
		$regs{$a1} = $v2;
	} elsif ($ins eq 'sub') {
		$regs{$a1} -= $v2;
	} elsif ($ins eq 'mul') {
		$regs{$a1} *= $v2;
		$muls++;
	} elsif ($ins eq 'jnz') {
		$pc += $v2-1 if $v1;
	} else {
		die "unknown insn $ins";
	}
	$pc++;
}

say $muls;
	

