S = 'NESW'*2 A = input() B = input() i = S.index(A) print(S[i:].index(B))