#include <bits/stdc++.h>

using namespace std;

int main() {
	int a, b, k;
	cin >> a >> b >> k;
	for (int i = 100; i; i--)
		if (a%i == 0 && b%i == 0 && !--k) {
			cout << i << endl;
			break;
		}
	return 0;
}
