#Words to Integer number
#Sample Input: three thousand two hundred; Output: 3200

num_dict = {'negative':'-','zero':'0','one':'1','two':'2','three':'3','four':'4','five':'5','six':'6','seven':'7','eight':'8','nine':'9','ten':'10','eleven':'11','twelve':'12','thirteen':'13','fourteen':'14',
            'fifteen':'15','sixteen':'16','seventeen':'17','eighteen':'18','nineteen':'19','twenty':'20','thirty':'30','forty':'40','fifty':'50','sixty':'60','seventy':'70','eighty':'80','ninety':'90','hundred':'100'}
            
mul_dict = {'hundred':'100', 'thousand':'1000','million':'1000000'}


line="negative three million fifty five thousand two hundred twenty one"
#print line,
neg = False;
words = line.split()
if words[0] == 'negative':
    neg = True
    words[:] = words[1:]
count =[0]*len(words)
i=0
for w in range(len(words)):
    if words[w] in mul_dict:
        count[i] = count[i] * int(mul_dict[words[w]])
        i+=1
    elif words[w] in num_dict:
        count[i]+= int(num_dict[words[w]])
if(neg):          
    print(-sum(count))
else:
    print(sum(count))
