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