import java.util.*;

public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
      	int number_a, number_b, number_k, i, count = 0;
      	number_a = Integer.parseInt(sc.next());
      	number_b = Integer.parseInt(sc.next());
      	number_k = Integer.parseInt(sc.next());
      for(i = Math.min(number_a, number_b); i > 0; i--) {
        if(number_a % i == 0 && number_b % i == 0) count++;
        if(count == number_k) break;
      }
      System.out.println(i);
    }
} import java.util.*; util.* java public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
      	int number_a, number_b, number_k, i, count = 0;
      	number_a = Integer.parseInt(sc.next());
      	number_b = Integer.parseInt(sc.next());
      	number_k = Integer.parseInt(sc.next());
      for(i = Math.min(number_a, number_b); i > 0; i--) {
        if(number_a % i == 0 && number_b % i == 0) count++;
        if(count == number_k) break;
      }
      System.out.println(i);
    }
} Main public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
      	int number_a, number_b, number_k, i, count = 0;
      	number_a = Integer.parseInt(sc.next());
      	number_b = Integer.parseInt(sc.next());
      	number_k = Integer.parseInt(sc.next());
      for(i = Math.min(number_a, number_b); i > 0; i--) {
        if(number_a % i == 0 && number_b % i == 0) count++;
        if(count == number_k) break;
      }
      System.out.println(i);
    } main {
    	Scanner sc = new Scanner(System.in);
      	int number_a, number_b, number_k, i, count = 0;
      	number_a = Integer.parseInt(sc.next());
      	number_b = Integer.parseInt(sc.next());
      	number_k = Integer.parseInt(sc.next());
      for(i = Math.min(number_a, number_b); i > 0; i--) {
        if(number_a % i == 0 && number_b % i == 0) count++;
        if(count == number_k) break;
      }
      System.out.println(i);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int number_a number_a number_b number_b number_k number_k i i count = 0; count 0 number_a = Integer.parseInt(sc.next()) number_a Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc number_b = Integer.parseInt(sc.next()) number_b Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc number_k = Integer.parseInt(sc.next()) number_k Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc for(i = Math.min(number_a, number_b); i > 0; i--) {
        if(number_a % i == 0 && number_b % i == 0) count++;
        if(count == number_k) break;
      } i = Math.min(number_a, number_b); i = Math.min(number_a, number_b) i Math.min(number_a, number_b) Math.min Math number_a number_b i > 0 i 0 i-- i-- i {
        if(number_a % i == 0 && number_b % i == 0) count++;
        if(count == number_k) break;
      } {
        if(number_a % i == 0 && number_b % i == 0) count++;
        if(count == number_k) break;
      } if(number_a % i == 0 && number_b % i == 0) count++; number_a % i == 0 && number_b % i == 0 number_a % i == 0 number_a % i number_a i 0 number_b % i == 0 number_b % i number_b i 0 count++ count if(count == number_k) break; count == number_k count number_k break; System.out.println(i) System.out.println System.out System System.out i String[] args args public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
      	int number_a, number_b, number_k, i, count = 0;
      	number_a = Integer.parseInt(sc.next());
      	number_b = Integer.parseInt(sc.next());
      	number_k = Integer.parseInt(sc.next());
      for(i = Math.min(number_a, number_b); i > 0; i--) {
        if(number_a % i == 0 && number_b % i == 0) count++;
        if(count == number_k) break;
      }
      System.out.println(i);
    }
} public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
      	int number_a, number_b, number_k, i, count = 0;
      	number_a = Integer.parseInt(sc.next());
      	number_b = Integer.parseInt(sc.next());
      	number_k = Integer.parseInt(sc.next());
      for(i = Math.min(number_a, number_b); i > 0; i--) {
        if(number_a % i == 0 && number_b % i == 0) count++;
        if(count == number_k) break;
      }
      System.out.println(i);
    }
} Main
import java.util.*;

public class Main {
	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
      	int number_a, number_b, number_k, i, count = 0;
      	number_a = Integer.parseInt(sc.next());
      	number_b = Integer.parseInt(sc.next());
      	number_k = Integer.parseInt(sc.next());
      for(i = Math.min(number_a, number_b); i > 0; i--) {
        if(number_a % i == 0 && number_b % i == 0) count++;
        if(count == number_k) break;
      }
      System.out.println(i);
    }
}