a=input() b=input() p='NESWNESW' for i in range(4): if p[i]==a: for j in range(4): if p[i+j]==b: print(j) break