map = {"E": 1, "W":3, "S":2, "N":4} A = input() B = input() print(abs(map[A]-map[B]))