print(('  SAFRTHWETUMOSU'.find(input()[:2])//2))
print((sum(map(ord,eval(input())+'\n'))**698%6329%8))
print(("  SAFRTHWETUMOSU".find(input()[:2]) // 2))

print((sum(map(ord, eval(input()) + "\n")) ** 698 % 6329 % 8))

-print(("  SAFRTHWETUMOSU".find(input()[:2]) // 2)) +print((sum(map(ord, eval(input()) + "\n")) ** 698 % 6329 % 8))