a = input() b = input() dic = {"N": 0, "E": 1, "S": 2, "W": 3} ans = (dic[b] - dic[a] + 4) % 4 print(ans)