import java.util.*;
public class Main {
	   public static int gcd(int x,int y){
        if(x < y) return gcd(y, x);
        if(y == 0) return x;
        return gcd(y, x % y);
    }
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int k = sc.nextInt(); 
      int count = 1;
      int ans = gcd(a,b);
      while(count<k){ans--;if(a%ans==0 &&b%ans==0){count++;}
                    }
	  System.out.println(ans);
  }
} import java.util.*; util.* java public class Main {
	   public static int gcd(int x,int y){
        if(x < y) return gcd(y, x);
        if(y == 0) return x;
        return gcd(y, x % y);
    }
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int k = sc.nextInt(); 
      int count = 1;
      int ans = gcd(a,b);
      while(count<k){ans--;if(a%ans==0 &&b%ans==0){count++;}
                    }
	  System.out.println(ans);
  }
} Main public static int gcd(int x,int y){
        if(x < y) return gcd(y, x);
        if(y == 0) return x;
        return gcd(y, x % y);
    } gcd {
        if(x < y) return gcd(y, x);
        if(y == 0) return x;
        return gcd(y, x % y);
    } if(x < y) return gcd(y, x); x < y x y return gcd(y, x); gcd(y, x) gcd y x if(y == 0) return x; y == 0 y 0 return x; x return gcd(y, x % y); gcd(y, x % y) gcd y x % y x y int x x int y y public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int k = sc.nextInt(); 
      int count = 1;
      int ans = gcd(a,b);
      while(count<k){ans--;if(a%ans==0 &&b%ans==0){count++;}
                    }
	  System.out.println(ans);
  } main {
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int k = sc.nextInt(); 
      int count = 1;
      int ans = gcd(a,b);
      while(count<k){ans--;if(a%ans==0 &&b%ans==0){count++;}
                    }
	  System.out.println(ans);
  } 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 int count = 1; count 1 int ans = gcd(a,b); ans gcd(a,b) gcd a b while(count<k){ans--;if(a%ans==0 &&b%ans==0){count++;}
                    } count<k count k {ans--;if(a%ans==0 &&b%ans==0){count++;}
                    } ans-- ans if(a%ans==0 &&b%ans==0){count++;} a%ans==0 &&b%ans==0 a%ans==0 a%ans a ans 0 b%ans==0 b%ans b ans 0 {count++;} count++ count System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {
	   public static int gcd(int x,int y){
        if(x < y) return gcd(y, x);
        if(y == 0) return x;
        return gcd(y, x % y);
    }
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int k = sc.nextInt(); 
      int count = 1;
      int ans = gcd(a,b);
      while(count<k){ans--;if(a%ans==0 &&b%ans==0){count++;}
                    }
	  System.out.println(ans);
  }
} public class Main {
	   public static int gcd(int x,int y){
        if(x < y) return gcd(y, x);
        if(y == 0) return x;
        return gcd(y, x % y);
    }
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int k = sc.nextInt(); 
      int count = 1;
      int ans = gcd(a,b);
      while(count<k){ans--;if(a%ans==0 &&b%ans==0){count++;}
                    }
	  System.out.println(ans);
  }
} Main
import java.util.*;
public class Main {
	   public static int gcd(int x,int y){
        if(x < y) return gcd(y, x);
        if(y == 0) return x;
        return gcd(y, x % y);
    }
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int k = sc.nextInt(); 
      int count = 1;
      int ans = gcd(a,b);
      while(count<k){ans--;if(a%ans==0 &&b%ans==0){count++;}
                    }
	  System.out.println(ans);
  }
}