s = 'NESWNESW'
a = input()
b = input()
print(s[s.index(a):].index(b))