print(("SATFRITHUWEDTUEMONSUN".index(eval(input()))//3+1))
s = eval(input())

l = ["SUN","MON","TUE","WED","THU","FRI","SAT","SUN"]

print((7 - l.index(s)))

print(("SATFRITHUWEDTUEMONSUN".index(eval(input())) // 3 + 1))

s = eval(input())
l = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"]
print((7 - l.index(s)))

-print(("SATFRITHUWEDTUEMONSUN".index(eval(input())) // 3 + 1)) +s = eval(input()) +l = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"] +print((7 - l.index(s)))