#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, a, b, k, count = 0, ans;
  cin >> a >> b >> k;
  for (i = min({a, b}); i > 0; i--) {
    if (a % i == 0 && b % i == 0) {
      count++;
    }
    if (count == k) {
      cout << i;
      return 0;
    }
  }
}
