import sys
from collections import defaultdict, Counter

lines = [line.strip().split() for line in sys.stdin if line]

pc = 0
regs = dict(zip('abcd', [0]*4))
regs['c'] = 1

def op(r):
    if r not in regs: return int(r)
    return regs[r]

while pc < len(lines):
    instr = lines[pc]
    #print pc, instr, regs
    if instr[0] == 'jnz' and op(instr[1]) != 0:
        pc += op(instr[2])  - 1
    elif instr[0] == 'inc':
        regs[instr[1]] += 1
    elif instr[0] == 'dec':
        regs[instr[1]] -= 1
    elif instr[0] == 'cpy':
        regs[instr[2]] = op(instr[1])
    pc += 1

print regs['a']

0f1b355c74e461f1e0a31fe6ee203096cb3eaef3
import sys
from collections import defaultdict, Counter

lines = [line.strip().split() for line in sys.stdin if line]

pc = 0
regs = dict(zip('abcd', [0]*4))
regs['c'] = 1

def op(r):
    if r not in regs: return int(r)
    return regs[r]

while pc < len(lines):
    instr = lines[pc]
    #print pc, instr, regs
    if instr[0] == 'jnz' and op(instr[1]) != 0:
        pc += op(instr[2])  - 1
    elif instr[0] == 'inc':
        regs[instr[1]] += 1
    elif instr[0] == 'dec':
        regs[instr[1]] -= 1
    elif instr[0] == 'cpy':
        regs[instr[2]] = op(instr[1])
    pc += 1

print regs['a']
