#yuki1806 l=list('NESWNESW') a=input() b=input() x=l.index(a) cnt=0 while l[x]!=b: x+=1 cnt+=1 print(cnt)