import sys #input = sys.stdin.readline #文字列につけてはダメ #input = sys.stdin.buffer.readline #文字列につけてはダメ #sys.setrecursionlimit(1000000) #import bisect #import itertools #import random #from heapq import heapify, heappop, heappush from collections import defaultdict #from collections import deque #import copy #import math #from functools import lru_cache #MOD = pow(10,9) + 7 #MOD = 998244353 def main(): A = input() B = input() L = ['N', 'E', 'S', 'W'] a = L.index(A) b = L.index(B) ans = b - a if ans < 0: ans += 4 print(ans) if __name__ == '__main__': main()