import std.stdio, std.conv, std.array, std.string, std.algorithm, std.range;

void main() {
  long a, b, k;
  readf("%d %d %d", &a, &b, &k);

  foreach_reverse (i; 1..min(a, b)+1) {
    if (a % i == 0 && b % i == 0) {
      k--;
      if (k == 0) {
        writeln(i);
        break;
      }
    }
  }
}
