h,d=0,0 for c,s in(x.strip().split()for x in open("input.txt")):v=int(s);h,d=(h+v,d)if c[0]=='f'else(h,d+(-v if c=='up'else v)) print(h*d)