f [] = True
f (x:[]) = True
f (x:y:xs) = if x==' ' && y==' ' then False else f xs 

main=do
 s<-getLine
 let x = filter(/=' ')x==s && last x/=' ' && head x/=' ' && f x
 print$sum$map sum$map (map read).words x 
　