import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int A = sc.nextInt();
    int B = sc.nextInt();
    int K = sc.nextInt() - 1;

    List<Integer> divisorA = cul(A);
    List<Integer> divisorB = cul(B);

    List<Integer> common = new ArrayList<>();

    for(Integer a : divisorA){
      if(divisorB.contains(a)){
        common.add(a);
      }
    }

    Collections.sort(common, Collections.reverseOrder());

    System.out.println(common.get(K));

  }

  public static List<Integer> cul(int number) {
    List<Integer> divisor = new ArrayList<>();

    for (int i = 1; i <= number ; i++ ) {
      if (number%i == 0) {
        divisor.add(i);
      }
    }

    return divisor;
  }
} import java.util.*; util.* java public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int A = sc.nextInt();
    int B = sc.nextInt();
    int K = sc.nextInt() - 1;

    List<Integer> divisorA = cul(A);
    List<Integer> divisorB = cul(B);

    List<Integer> common = new ArrayList<>();

    for(Integer a : divisorA){
      if(divisorB.contains(a)){
        common.add(a);
      }
    }

    Collections.sort(common, Collections.reverseOrder());

    System.out.println(common.get(K));

  }

  public static List<Integer> cul(int number) {
    List<Integer> divisor = new ArrayList<>();

    for (int i = 1; i <= number ; i++ ) {
      if (number%i == 0) {
        divisor.add(i);
      }
    }

    return divisor;
  }
} Main public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int A = sc.nextInt();
    int B = sc.nextInt();
    int K = sc.nextInt() - 1;

    List<Integer> divisorA = cul(A);
    List<Integer> divisorB = cul(B);

    List<Integer> common = new ArrayList<>();

    for(Integer a : divisorA){
      if(divisorB.contains(a)){
        common.add(a);
      }
    }

    Collections.sort(common, Collections.reverseOrder());

    System.out.println(common.get(K));

  } main {
    Scanner sc = new Scanner(System.in);

    int A = sc.nextInt();
    int B = sc.nextInt();
    int K = sc.nextInt() - 1;

    List<Integer> divisorA = cul(A);
    List<Integer> divisorB = cul(B);

    List<Integer> common = new ArrayList<>();

    for(Integer a : divisorA){
      if(divisorB.contains(a)){
        common.add(a);
      }
    }

    Collections.sort(common, Collections.reverseOrder());

    System.out.println(common.get(K));

  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int A = sc.nextInt(); A sc.nextInt() sc.nextInt sc int B = sc.nextInt(); B sc.nextInt() sc.nextInt sc int K = sc.nextInt() - 1; K sc.nextInt() - 1 sc.nextInt() sc.nextInt sc 1 List<Integer> divisorA = cul(A); divisorA cul(A) cul A List<Integer> divisorB = cul(B); divisorB cul(B) cul B List<Integer> common = new ArrayList<>(); common new ArrayList<>() for(Integer a : divisorA){
      if(divisorB.contains(a)){
        common.add(a);
      }
    } Integer a divisorA {
      if(divisorB.contains(a)){
        common.add(a);
      }
    } {
      if(divisorB.contains(a)){
        common.add(a);
      }
    } if(divisorB.contains(a)){
        common.add(a);
      } divisorB.contains(a) divisorB.contains divisorB a {
        common.add(a);
      } common.add(a) common.add common a Collections.sort(common, Collections.reverseOrder()) Collections.sort Collections common Collections.reverseOrder() Collections.reverseOrder Collections System.out.println(common.get(K)) System.out.println System.out System System.out common.get(K) common.get common K String[] args args public static List<Integer> cul(int number) {
    List<Integer> divisor = new ArrayList<>();

    for (int i = 1; i <= number ; i++ ) {
      if (number%i == 0) {
        divisor.add(i);
      }
    }

    return divisor;
  } cul {
    List<Integer> divisor = new ArrayList<>();

    for (int i = 1; i <= number ; i++ ) {
      if (number%i == 0) {
        divisor.add(i);
      }
    }

    return divisor;
  } List<Integer> divisor = new ArrayList<>(); divisor new ArrayList<>() for (int i = 1; i <= number ; i++ ) {
      if (number%i == 0) {
        divisor.add(i);
      }
    } int i = 1; int i = 1; i 1 i <= number i number i++ i++ i {
      if (number%i == 0) {
        divisor.add(i);
      }
    } {
      if (number%i == 0) {
        divisor.add(i);
      }
    } if (number%i == 0) {
        divisor.add(i);
      } number%i == 0 number%i number i 0 {
        divisor.add(i);
      } divisor.add(i) divisor.add divisor i return divisor; divisor int number number public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int A = sc.nextInt();
    int B = sc.nextInt();
    int K = sc.nextInt() - 1;

    List<Integer> divisorA = cul(A);
    List<Integer> divisorB = cul(B);

    List<Integer> common = new ArrayList<>();

    for(Integer a : divisorA){
      if(divisorB.contains(a)){
        common.add(a);
      }
    }

    Collections.sort(common, Collections.reverseOrder());

    System.out.println(common.get(K));

  }

  public static List<Integer> cul(int number) {
    List<Integer> divisor = new ArrayList<>();

    for (int i = 1; i <= number ; i++ ) {
      if (number%i == 0) {
        divisor.add(i);
      }
    }

    return divisor;
  }
} public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int A = sc.nextInt();
    int B = sc.nextInt();
    int K = sc.nextInt() - 1;

    List<Integer> divisorA = cul(A);
    List<Integer> divisorB = cul(B);

    List<Integer> common = new ArrayList<>();

    for(Integer a : divisorA){
      if(divisorB.contains(a)){
        common.add(a);
      }
    }

    Collections.sort(common, Collections.reverseOrder());

    System.out.println(common.get(K));

  }

  public static List<Integer> cul(int number) {
    List<Integer> divisor = new ArrayList<>();

    for (int i = 1; i <= number ; i++ ) {
      if (number%i == 0) {
        divisor.add(i);
      }
    }

    return divisor;
  }
} Main
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int A = sc.nextInt();
    int B = sc.nextInt();
    int K = sc.nextInt() - 1;

    List<Integer> divisorA = cul(A);
    List<Integer> divisorB = cul(B);

    List<Integer> common = new ArrayList<>();

    for(Integer a : divisorA){
      if(divisorB.contains(a)){
        common.add(a);
      }
    }

    Collections.sort(common, Collections.reverseOrder());

    System.out.println(common.get(K));

  }

  public static List<Integer> cul(int number) {
    List<Integer> divisor = new ArrayList<>();

    for (int i = 1; i <= number ; i++ ) {
      if (number%i == 0) {
        divisor.add(i);
      }
    }

    return divisor;
  }
}
