S = "ESWN" * 3 A = input() B = input() i = S.index(A) j = S.index(B) ans = j - i if ans < 0: ans += 4 print(ans)