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