import sys
import re
#re.match("\(_S+\) (\S\)+")
#dfs = []
#def recurse(root, succs):
#    global dfs
#    for n in succs[root][1]:
#        #print(last)
#        recurse(n, succs)
#    dfs.append(root)
def incop(r, val):
    return r + val
def decop(r, val):
    return r - val
def ceq(r, val):
    return r == val
def clt(r, val):
    return r < val
def cle(r, val):
    return r <= val
def cgt(r, val):
    return r > val
def cge(r, val):
    return r >= val
def cne(r, val):
    return r != val
    
def decop(r, val):
    return r - val
    #kd dec -37 if gm <= 9
def doit(input):
    max = 0
    regs = {}
    lines  = input.split("\n")
    for l in lines:
        w = l.split()
        #print(w)
        r = w[0]
        op = w[1]
        val = int(w[2])
        cr = w[4]
        cop = w[5]
        cval = int(w[6])
        if cop == "==":
            pred = ceq
        elif cop == "<":
            pred = clt
        elif cop == "<=":
            pred = cle
        elif cop == ">":
            pred = cgt
        elif cop == ">=":
            pred = cge
        elif cop == "!=":
            pred = cne
        if op == "inc":
            oper = incop
        else:
            oper = decop
        if cr not in regs: regs[cr] = 0
        if r not in regs: regs[r] = 0 
        res=pred(regs[cr], cval)
        if res:
            res = oper(regs[r],val)
            regs[r] = res
        for r in regs:
            if regs[r] > max:
                max = regs[r]
    return "%s" % (max)
input = sys.stdin.read()
print(doit(input))