s = "ESWN" x, y = input(), input() for i in range(4): if x == s[i]: x = i if y == s[i]: y = i print((y - x + 4) % 4)