def D(X): return "NESW".index(X) A = int(input()) B = int(input()) print((D(B) - D(A) + 4) % 4)