import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
 
public class Main {
 
  public static void main(String[] args) throws FileNotFoundException {
 
//    Scanner cin = new Scanner(new FileReader("input.txt"));
    Scanner cin = new Scanner(System.in);
 
    int a = cin.nextInt();
    int b = cin.nextInt();
    int c = cin.nextInt();
 
    int d = a < b ? a : b;
 
    ArrayList<Integer> factor = new ArrayList<>();
 
    for (int i = 1; i <= d; i++) {
 
      if (a % i == 0 && b % i == 0)
        factor.add(i);
    }
    Collections.sort(factor, Collections.reverseOrder());
    System.out.println(factor.get(c - 1));
  }
 
} import java.io.FileNotFoundException; FileNotFoundException java.io import java.io.FileReader; FileReader java.io import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.util.Scanner; Scanner java.util public class Main {
 
  public static void main(String[] args) throws FileNotFoundException {
 
//    Scanner cin = new Scanner(new FileReader("input.txt"));
    Scanner cin = new Scanner(System.in);
 
    int a = cin.nextInt();
    int b = cin.nextInt();
    int c = cin.nextInt();
 
    int d = a < b ? a : b;
 
    ArrayList<Integer> factor = new ArrayList<>();
 
    for (int i = 1; i <= d; i++) {
 
      if (a % i == 0 && b % i == 0)
        factor.add(i);
    }
    Collections.sort(factor, Collections.reverseOrder());
    System.out.println(factor.get(c - 1));
  }
 
} Main public static void main(String[] args) throws FileNotFoundException {
 
//    Scanner cin = new Scanner(new FileReader("input.txt"));
    Scanner cin = new Scanner(System.in);
 
    int a = cin.nextInt();
    int b = cin.nextInt();
    int c = cin.nextInt();
 
    int d = a < b ? a : b;
 
    ArrayList<Integer> factor = new ArrayList<>();
 
    for (int i = 1; i <= d; i++) {
 
      if (a % i == 0 && b % i == 0)
        factor.add(i);
    }
    Collections.sort(factor, Collections.reverseOrder());
    System.out.println(factor.get(c - 1));
  } main {
 
//    Scanner cin = new Scanner(new FileReader("input.txt"));
    Scanner cin = new Scanner(System.in);
 
    int a = cin.nextInt();
    int b = cin.nextInt();
    int c = cin.nextInt();
 
    int d = a < b ? a : b;
 
    ArrayList<Integer> factor = new ArrayList<>();
 
    for (int i = 1; i <= d; i++) {
 
      if (a % i == 0 && b % i == 0)
        factor.add(i);
    }
    Collections.sort(factor, Collections.reverseOrder());
    System.out.println(factor.get(c - 1));
  } Scanner cin = new Scanner(System.in); cin new Scanner(System.in) int a = cin.nextInt(); a cin.nextInt() cin.nextInt cin int b = cin.nextInt(); b cin.nextInt() cin.nextInt cin int c = cin.nextInt(); c cin.nextInt() cin.nextInt cin int d = a < b ? a : b; d a < b ? a : b a < b a b a b ArrayList<Integer> factor = new ArrayList<>(); factor new ArrayList<>() for (int i = 1; i <= d; i++) {
 
      if (a % i == 0 && b % i == 0)
        factor.add(i);
    } int i = 1; int i = 1; i 1 i <= d i d i++ i++ i {
 
      if (a % i == 0 && b % i == 0)
        factor.add(i);
    } {
 
      if (a % i == 0 && b % i == 0)
        factor.add(i);
    } if (a % i == 0 && b % i == 0)
        factor.add(i); a % i == 0 && b % i == 0 a % i == 0 a % i a i 0 b % i == 0 b % i b i 0 factor.add(i) factor.add factor i Collections.sort(factor, Collections.reverseOrder()) Collections.sort Collections factor Collections.reverseOrder() Collections.reverseOrder Collections System.out.println(factor.get(c - 1)) System.out.println System.out System System.out factor.get(c - 1) factor.get factor c - 1 c 1 String[] args args public class Main {
 
  public static void main(String[] args) throws FileNotFoundException {
 
//    Scanner cin = new Scanner(new FileReader("input.txt"));
    Scanner cin = new Scanner(System.in);
 
    int a = cin.nextInt();
    int b = cin.nextInt();
    int c = cin.nextInt();
 
    int d = a < b ? a : b;
 
    ArrayList<Integer> factor = new ArrayList<>();
 
    for (int i = 1; i <= d; i++) {
 
      if (a % i == 0 && b % i == 0)
        factor.add(i);
    }
    Collections.sort(factor, Collections.reverseOrder());
    System.out.println(factor.get(c - 1));
  }
 
} public class Main {
 
  public static void main(String[] args) throws FileNotFoundException {
 
//    Scanner cin = new Scanner(new FileReader("input.txt"));
    Scanner cin = new Scanner(System.in);
 
    int a = cin.nextInt();
    int b = cin.nextInt();
    int c = cin.nextInt();
 
    int d = a < b ? a : b;
 
    ArrayList<Integer> factor = new ArrayList<>();
 
    for (int i = 1; i <= d; i++) {
 
      if (a % i == 0 && b % i == 0)
        factor.add(i);
    }
    Collections.sort(factor, Collections.reverseOrder());
    System.out.println(factor.get(c - 1));
  }
 
} Main
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
 
public class Main {
 
  public static void main(String[] args) throws FileNotFoundException {
 
//    Scanner cin = new Scanner(new FileReader("input.txt"));
    Scanner cin = new Scanner(System.in);
 
    int a = cin.nextInt();
    int b = cin.nextInt();
    int c = cin.nextInt();
 
    int d = a < b ? a : b;
 
    ArrayList<Integer> factor = new ArrayList<>();
 
    for (int i = 1; i <= d; i++) {
 
      if (a % i == 0 && b % i == 0)
        factor.add(i);
    }
    Collections.sort(factor, Collections.reverseOrder());
    System.out.println(factor.get(c - 1));
  }
 
}