#include <bits/stdc++.h>
using namespace std;
int main() {
  int A, B, K;
  cin >> A >> B >> K;
  vector<int> answer;
  answer.push_back(1);
  for (int i = 2; i <= min(A, B); i++) {
    if ((A % i == 0) && (B % i == 0)) {
      answer.push_back(i);
    }
  }
  cout << answer[K - 1] << endl;
  return 0;
}
