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