A = input() B = input() dir = ['N', 'E', 'S', 'W'] a = dir.index(A) b = dir.index(B) ans = (b+4-a)%4 print(ans)