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