#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){
	int A,B,K;
	cin >> A >> B >> K;
	int k = euclidean_gcd(A,B);
	int ans = k;
	int i = 0;

	while(true){
		if (k % ans == 0) {
			i++;
		}
		if (i == K) {
			break;
		}
		ans--;
	}
	cout << ans;
	
	return 0;
}
