A = input() B = input() C = ["N", "E", "S", "W"] s = C.index(A) t = C.index(B) print(((t + 4) - s) % 4)