a = input()
b = input()

d = { 'N' : 0, 'E' : 1, 'S' : 2, 'W' : 3 }
ans = (d[b] - d[a] + 4) % 4

print(ans)