#include"bits/stdc++.h" using namespace std; int main() { long int a0, a1, n; cin >> a0 >> a1 >> n; long int m; for (int i = 2; i <= n; i++) { m = a1 ^ a0; a0 = a1; a1 = m; } cout << m << endl; }