t = {} t.N = 1 t.E = 2 t.S = 3 t.W = 4 a = io.read() b = io.read() print((4 + t[b] - t[a]) % 4)