a = input() b = input() #E, W, S, N if a == "E": a = 0 if a == "S": a = 1 if a == "W": a = 2 if a == "N": a = 3 if b== "E": b = 0 if b == "S": b = 1 if b == "W": b = 2 if b == "N": b = 3 cnt = 0 while True: #print(a,b) if a ==b: print(cnt) exit() a += 1 a %= 4 cnt += 1