A = input() B = input() ls = ['E','S','W','N'] ind = ls.index(A) for i in range(4): if ls[(ind+i)%4] == B: print(i) break