import sys input = sys.stdin.readline A=input().strip() B=input().strip() D={"E":0,"S":1,"W":2,"N":3} A=D[A] B=D[B] print((B-A)%4)