f,g,N=map(int,input().split()) if N==0 or N==1:g=f else: while N>1: f,g,N=g,g^f,N-1 print(g)