from sys import stdin def inputSynario(): input = stdin.readline A = input().rstrip() B = input().rstrip() return A,B def toNum(str): if(str=="N"): return 0 elif(str=="E"): return 3 elif(str=="S"): return 2 else: return 1 (A,B)=inputSynario() a = toNum(A)+4 b = toNum(B) print((a-b)%4)