A = input()
B = input()
S = "NESW"
print((S.index(B) - S.index(A)) % 4)