A=input() B=input() D="NESW"*10 a=D.index(A) k=0 while D[a+k]!=B: k+=1 print(k)