import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//String tmp = sc.next();
		//int tmp = sc.nextInt();
		//Long tmp = sc.nextLong();
      int A = sc.nextInt();
      int B = sc.nextInt();
      int K = sc.nextInt();
      ArrayList<Integer> aList = new ArrayList<Integer>(A);
      ArrayList<Integer> bList = new ArrayList<Integer>(B);
      for(int i = 1; i <= A; i++){
        if(A % i == 0){
          aList.add(i);
        }
      }
      for(int i = 1; i <= B; i++){
        if(B % i == 0){
          bList.add(i);
        }
      }
      //System.out.println(aList);
      //System.out.println(bList);
      for(int i = 0; i < aList.size(); i++){
        if(bList.indexOf(aList.get(i)) == -1){
          aList.remove(aList.get(i));
          i--;
        }
      }
      //System.out.println(aList);
      System.out.println(aList.get(aList.size() - K));
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//String tmp = sc.next();
		//int tmp = sc.nextInt();
		//Long tmp = sc.nextLong();
      int A = sc.nextInt();
      int B = sc.nextInt();
      int K = sc.nextInt();
      ArrayList<Integer> aList = new ArrayList<Integer>(A);
      ArrayList<Integer> bList = new ArrayList<Integer>(B);
      for(int i = 1; i <= A; i++){
        if(A % i == 0){
          aList.add(i);
        }
      }
      for(int i = 1; i <= B; i++){
        if(B % i == 0){
          bList.add(i);
        }
      }
      //System.out.println(aList);
      //System.out.println(bList);
      for(int i = 0; i < aList.size(); i++){
        if(bList.indexOf(aList.get(i)) == -1){
          aList.remove(aList.get(i));
          i--;
        }
      }
      //System.out.println(aList);
      System.out.println(aList.get(aList.size() - K));
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//String tmp = sc.next();
		//int tmp = sc.nextInt();
		//Long tmp = sc.nextLong();
      int A = sc.nextInt();
      int B = sc.nextInt();
      int K = sc.nextInt();
      ArrayList<Integer> aList = new ArrayList<Integer>(A);
      ArrayList<Integer> bList = new ArrayList<Integer>(B);
      for(int i = 1; i <= A; i++){
        if(A % i == 0){
          aList.add(i);
        }
      }
      for(int i = 1; i <= B; i++){
        if(B % i == 0){
          bList.add(i);
        }
      }
      //System.out.println(aList);
      //System.out.println(bList);
      for(int i = 0; i < aList.size(); i++){
        if(bList.indexOf(aList.get(i)) == -1){
          aList.remove(aList.get(i));
          i--;
        }
      }
      //System.out.println(aList);
      System.out.println(aList.get(aList.size() - K));
	} main {
		Scanner sc = new Scanner(System.in);
		//String tmp = sc.next();
		//int tmp = sc.nextInt();
		//Long tmp = sc.nextLong();
      int A = sc.nextInt();
      int B = sc.nextInt();
      int K = sc.nextInt();
      ArrayList<Integer> aList = new ArrayList<Integer>(A);
      ArrayList<Integer> bList = new ArrayList<Integer>(B);
      for(int i = 1; i <= A; i++){
        if(A % i == 0){
          aList.add(i);
        }
      }
      for(int i = 1; i <= B; i++){
        if(B % i == 0){
          bList.add(i);
        }
      }
      //System.out.println(aList);
      //System.out.println(bList);
      for(int i = 0; i < aList.size(); i++){
        if(bList.indexOf(aList.get(i)) == -1){
          aList.remove(aList.get(i));
          i--;
        }
      }
      //System.out.println(aList);
      System.out.println(aList.get(aList.size() - 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(); K sc.nextInt() sc.nextInt sc ArrayList<Integer> aList = new ArrayList<Integer>(A); aList new ArrayList<Integer>(A) ArrayList<Integer> bList = new ArrayList<Integer>(B); bList new ArrayList<Integer>(B) for(int i = 1; i <= A; i++){
        if(A % i == 0){
          aList.add(i);
        }
      } int i = 1; int i = 1; i 1 i <= A i A i++ i++ i {
        if(A % i == 0){
          aList.add(i);
        }
      } {
        if(A % i == 0){
          aList.add(i);
        }
      } if(A % i == 0){
          aList.add(i);
        } A % i == 0 A % i A i 0 {
          aList.add(i);
        } aList.add(i) aList.add aList i for(int i = 1; i <= B; i++){
        if(B % i == 0){
          bList.add(i);
        }
      } int i = 1; int i = 1; i 1 i <= B i B i++ i++ i {
        if(B % i == 0){
          bList.add(i);
        }
      } {
        if(B % i == 0){
          bList.add(i);
        }
      } if(B % i == 0){
          bList.add(i);
        } B % i == 0 B % i B i 0 {
          bList.add(i);
        } bList.add(i) bList.add bList i for(int i = 0; i < aList.size(); i++){
        if(bList.indexOf(aList.get(i)) == -1){
          aList.remove(aList.get(i));
          i--;
        }
      } int i = 0; int i = 0; i 0 i < aList.size() i aList.size() aList.size aList i++ i++ i {
        if(bList.indexOf(aList.get(i)) == -1){
          aList.remove(aList.get(i));
          i--;
        }
      } {
        if(bList.indexOf(aList.get(i)) == -1){
          aList.remove(aList.get(i));
          i--;
        }
      } if(bList.indexOf(aList.get(i)) == -1){
          aList.remove(aList.get(i));
          i--;
        } bList.indexOf(aList.get(i)) == -1 bList.indexOf(aList.get(i)) bList.indexOf bList aList.get(i) aList.get aList i -1 1 {
          aList.remove(aList.get(i));
          i--;
        } aList.remove(aList.get(i)) aList.remove aList aList.get(i) aList.get aList i i-- i System.out.println(aList.get(aList.size() - K)) System.out.println System.out System System.out aList.get(aList.size() - K) aList.get aList aList.size() - K aList.size() aList.size aList K String[] args args public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//String tmp = sc.next();
		//int tmp = sc.nextInt();
		//Long tmp = sc.nextLong();
      int A = sc.nextInt();
      int B = sc.nextInt();
      int K = sc.nextInt();
      ArrayList<Integer> aList = new ArrayList<Integer>(A);
      ArrayList<Integer> bList = new ArrayList<Integer>(B);
      for(int i = 1; i <= A; i++){
        if(A % i == 0){
          aList.add(i);
        }
      }
      for(int i = 1; i <= B; i++){
        if(B % i == 0){
          bList.add(i);
        }
      }
      //System.out.println(aList);
      //System.out.println(bList);
      for(int i = 0; i < aList.size(); i++){
        if(bList.indexOf(aList.get(i)) == -1){
          aList.remove(aList.get(i));
          i--;
        }
      }
      //System.out.println(aList);
      System.out.println(aList.get(aList.size() - K));
	}
} public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//String tmp = sc.next();
		//int tmp = sc.nextInt();
		//Long tmp = sc.nextLong();
      int A = sc.nextInt();
      int B = sc.nextInt();
      int K = sc.nextInt();
      ArrayList<Integer> aList = new ArrayList<Integer>(A);
      ArrayList<Integer> bList = new ArrayList<Integer>(B);
      for(int i = 1; i <= A; i++){
        if(A % i == 0){
          aList.add(i);
        }
      }
      for(int i = 1; i <= B; i++){
        if(B % i == 0){
          bList.add(i);
        }
      }
      //System.out.println(aList);
      //System.out.println(bList);
      for(int i = 0; i < aList.size(); i++){
        if(bList.indexOf(aList.get(i)) == -1){
          aList.remove(aList.get(i));
          i--;
        }
      }
      //System.out.println(aList);
      System.out.println(aList.get(aList.size() - K));
	}
} Main
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//String tmp = sc.next();
		//int tmp = sc.nextInt();
		//Long tmp = sc.nextLong();
      int A = sc.nextInt();
      int B = sc.nextInt();
      int K = sc.nextInt();
      ArrayList<Integer> aList = new ArrayList<Integer>(A);
      ArrayList<Integer> bList = new ArrayList<Integer>(B);
      for(int i = 1; i <= A; i++){
        if(A % i == 0){
          aList.add(i);
        }
      }
      for(int i = 1; i <= B; i++){
        if(B % i == 0){
          bList.add(i);
        }
      }
      //System.out.println(aList);
      //System.out.println(bList);
      for(int i = 0; i < aList.size(); i++){
        if(bList.indexOf(aList.get(i)) == -1){
          aList.remove(aList.get(i));
          i--;
        }
      }
      //System.out.println(aList);
      System.out.println(aList.get(aList.size() - K));
	}
}
