A = input() B = input() S = "NESWNESW" for st in range(4): if S[st] == A: break for i in range(st,8): if S[i] == B: print (i-st) break