import sys f = [0] * 3 f[0], f[1], N = map(int, input().split()) if N < 2: print(f[N]) sys.exit() for i in range(2, N+1): f[2] = f[0] ^ f[1] f[0], f[1], = f[1], f[2] print(f[2])