lst = ['N', 'E', 'S', 'W'] A, B = [input().strip() for _ in range(2)] a = lst.index(A) b = lst.index(B) print((b - a) % len(lst))