list = ["N", "E", "S", "W"] start = list.index(input()) goal = list.index(input()) diff = goal -start if diff >= 0: print(diff) else: print(diff+4)