def Main(): a=input() b=input() s="EWSNEWSN" k=s.find(a) for i in range(k,8): if s[i]==b: print(i-k) return Main()