directions = {'N': 0, 'E': 1, 'S': 2, 'W': 3}
a = input().strip()
b = input().strip()
diff = (directions[b] - directions[a]) % 4
print(diff)