def fib(F0, F1, N): if N == 2: return F0 ^ F1 else: return fib(F1, F0^F1, N-1) F0, F1, N = [int(i) for i in input().split()] print(fib(F0, F1, N))