A = input() B = input() def f(x): if x == "E": return 0 if x == "S": return 1 if x == "W": return 2 if x == "N": return 3 print((f(B)-f(A)+4)%4)