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