right = ['N', 'E', 'S', 'W'] A = input() B = input() cnt = 0 l = right.index(A) for i in range(4): if l%4 == right.index(B): break l += 1 cnt += 1 print(cnt)