def Main(): s=["E","S","W","N","E","S","W","N"] a=input() b=input() ans=0 for i in range(s.index(a),8): if s[i]==b: print(ans) exit() ans+=1 Main()