D = ['N', 'E', 'S', 'W'] a = input() b = input() f, t = -1, -1 for i in range(4): if D[i] == a: f = i if D[i] == b: t = i print((t + 4 - f) % 4)