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