A = [input().split() for _ in range(2)] d = {"E": 1, "S": 2, "W": 3, "N": 4} b = abs(d[A[1][0]] - d[A[0][0]]) if b == 3: b = 1 print(b)