A = str(input()) B = str(input()) if A=="N": A = 0 elif A=="E": A = 1 elif A=="S": A = 2 elif A =="W": A = 3 if B == "N": B = 0 elif B=="E": B = 1 elif B=="S": B = 2 elif B =="W": B = 3 k=0 k = int(B)-int(A) if k < 0: k=k+4 print(k)