a,b,N = map(int,raw_input().split()) count = 0 c = a d = b stack = [b,a] while N>count: c = a d = b b = (c^d) a = d count += 1 print a