import sys input = sys.stdin.readline dirs = { 'N': 0, 'E': 1, 'S': 2, 'W': 3 } a = dirs[input()[:-1]] b = dirs[input()[:-1]] ans = (b - a + 4) % 4 print(ans)