idx = {}
idx['E'] = 0
idx['S'] = 1
idx['W'] = 2
idx['N'] = 3
a = input()
b = input()
print((idx[b] - idx[a]) % 4)