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

int main() {
  int A,B,K;
  cin >> A >> B >> K;
  int now = min(A,B);
  while (K > 0) {
    if (A%now == 0 && B%now == 0) {
      K--;
    }
    now--;
  }
  cout << now+1 << endl;
}