S = "NESW" d = {s: i for i, s in enumerate(S)} A = input() B = input() ans = d[B] - d[A] if ans < 0: ans += 4 print(ans)