from sys import stdin
readline = stdin.readline
a = str(readline().rstrip('\n'))
if a == 'N':
    news = {'N':0,'E':1,'S':2,'W':3}
elif a == 'E':
    news = {'E':0,'S':1,'W':2,'N':3}
elif a == 'S':
    news = {'S':0,'W':1,'N':2,'E':3}
elif a == 'W':
    news = {'W':0,'N':1,'E':2,'S':3}
else:
    news = {'N':0,'E':1,'S':2,'W':3}
b = str(readline().rstrip('\n'))
print(news[b])