#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <numeric>
#include <iomanip>

using namespace std;


void atcoder_beginner_contest999()
{
  string n;
  cin >> n;

  for (int i = 0; i < n.size(); ++i)
  {
    if (n[i] == '1') n[i] = '9';
    else if (n[i] == '9') n[i] = '1';
  }
  cout << n << "\n";
}


void programming_education()
{
  int n;
  cin >> n;
  
  if (n == 1)
  {
    cout << "Hello World\n";
    return;
  }
  else
  {
    int a, b;
    cin >> a >> b;
    cout << a + b << "\n";
  }
}

void discount_fare()
{
  int x, y;
  cin >> x >> y;

  cout << x + y / 2 << "\n";
}


void A_114()
{
  int x;
  cin >> x;

  if (x == 3 || x == 5 || x == 7) cout << "YES\n";
  else cout << "NO\n";
}


void christmas_eve_eve_eve()
{
  int d;
  cin >> d;

  if (d == 25) cout << "Christmas\n";
  else if (d == 24) cout << "Christmas Eve\n";
  if (d == 23) cout << "Christmas Eve Eve\n";
  if (d == 22) cout << "Christmas Eve Eve Eve\n";
}


void right_triangle()
{
  int a, b, c;
  cin >> a >> b >> c;

  cout << a * b / 2 << "\n";
}


void entrance_examination()
{
  int t, x;
  cin >> t >> x;

  cout << (double)t / (double)x << "\n";
}


void A_118()
{
  int a, b;
  cin >> a >> b;

  if (b % a == 0) cout << a + b << "\n";
  else cout << b - a << "\n";
}


void still_TBD()
{
  string s;
  cin >> s;

  if (s[5] == '1' || s[6] >= '5') cout << "TBD\n";
  else cout << "Heisei\n";
}


void favorite_sound()
{
  int a, b, c;
  cin >> a >> b >> c;

  cout << min(b / a, c) << "\n";
}


void atcoder_beginner_contest111()
{
  int n;
  cin >> n;

  if (n % 111 == 0) cout << n << "\n";
  else
  {
    int a = n / 111;
    ++a;
    cout << a * 111 << "\n";
  }
}


void time_limit_exceeded()
{
  int N, T;
  cin >> N >> T;

  int ans = 1001;
  for (int i = 0; i < N; ++i)
  {
    int c, t;
    cin >> c >> t;

    if (t <= T && c < ans) ans = c;
  }
  if (ans == 1001) cout << "TLE\n";
  else cout << ans << "\n";
}


void palace()
{
  int n, t, a;
  cin >> n >> t >> a;

  double d_min = 1000;
  int ans = 0;
  for (int i = 1; i <= n; ++i)
  {
    int h;
    cin >> h;
    double d = (t - h * 0.006) - a;
    if (d < 0) d *= -1;
    if (d < d_min)
    {
      d_min = d;
      ans = i;
    }
  }
  cout << ans << "\n";
}


void B_114()
{
  string s;
  cin >> s;

  int ans = 1000;
  for (int i = 0; i < s.size() - 2;++i)
  {
    int now_s = stoi(s.substr(i,3));
    ans = min(ans, abs(753 - now_s));
  }
  cout << ans << "\n";
}


void christmas_eve_eve()
{
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; ++i) cin >> p[i];

  sort(p.begin(), p.end());

  int v_sum = 0;
  for (int i = 0; i < n; ++i)
  {
    if (i == n - 1) v_sum += p[i] / 2;
    else v_sum += p[i];
  }
  cout << v_sum << "\n";
}


void collatz_problem()
{
  int s;
  cin >> s;
  map<int, int> mp;

  int a = s, ans;
  for (int i = 1; i < 1000001; ++i)
  {
    if (mp[a] != 0)
    {
      ans = i;
      break;
    }
    else
    {
      ++mp[a];
      if (a % 2 == 0) a /= 2;
      else a = 3 * a + 1;
    }
  }
  cout << ans << "\n";
}


void polygon()
{
  int n;
  cin >> n;
  vector<int> l(n);
  for (int i = 0; i < n; ++i) cin >> l[i];

  sort(l.begin(), l.end());

  int v_sum = accumulate(l.begin(), l.end() - 1,0);
  if (l[n - 1] < v_sum) cout << "Yes\n";
  else cout << "No\n";
}

//skip
void foods_loved_by_everyone()
{

}


void digital_gifts()
{
  int n;
  cin >> n;
  vector<double> x(n);
  vector<string> u(n);
  for (int i = 0; i < n; ++i) cin >> x[i] >> u[i];

  double v_sum = 0;
  for (int i = 0; i < n; ++i)
  {
    if (u[i] == "JPY") v_sum += x[i];
    else v_sum += 380000.0 * x[i];
  }
  cout << v_sum << "\n";
}


void k_th_common_divisor()
{
  int a, b, k;
  cin >> a >> b >> k;

  int cnt = 0;
  for (int i = min(a,b); i >= 0; --i)
  {
    if (a % i == 0 && b % i == 0) ++cnt;
    if (k == cnt)
    {
      cout << i << "\n";
      return;
    }
  }
}


int main()
{
  //atcoder_beginner_contest999();
  //programming_education();
  //discount_fare();
  //A_114();
  //christmas_eve_eve_eve();
  //right_triangle();
  //entrance_examination();
  //A_118();
  //still_TBD();
  //favorite_sound();

  //atcoder_beginner_contest111();
  //time_limit_exceeded();
  //palace();
  //B_114();
  //christmas_eve_eve();
  //collatz_problem();
  //polygon();
  //foods_loved_by_everyone();
  //digital_gifts();
  k_th_common_divisor();
}

Measured memory_bytes: 256