while True:
s=[i for i in input().upper()]
ans=0
if s[0]=="0" and len(s)==1:break
while len(s)!=0:
if s[:9]==["K","N","O","W","L","E","D","G","E"]:ans+=96;del s[:9]
elif s[:8]==["H","A","R","D","W","O","R","K"]:ans+=98;del s[:8]
elif s[:8]==["A","T","T","I","T","U","D","E"]:ans+=100;del s[:8]
else:print("Fail");break
else:print(ans)