A = input() B = input() g = ["N", "E", "S", "W"] x = g.index(A) y = g.index(B) s = y - x if s < 0: s += 4 print(s)