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();
		System.out.println(getCD(a,b,k));
	}
	private static int getCD(int a,int b,int k){
		int n=k;
		for(int i=chmin(a,b);i>0;i--){
			if(a%i==0 && b%i==0){
				n--;
				if(n==0)return i;
			}
		}
		return 0;
	}
	private static int chmax(int a,int b){
		if(a>b) return a;
		else return b;
	}
	private static int chmin(int a,int b){
		if(a<b) return a;
		else return b;
	}
} 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();
		System.out.println(getCD(a,b,k));
	}
	private static int getCD(int a,int b,int k){
		int n=k;
		for(int i=chmin(a,b);i>0;i--){
			if(a%i==0 && b%i==0){
				n--;
				if(n==0)return i;
			}
		}
		return 0;
	}
	private static int chmax(int a,int b){
		if(a>b) return a;
		else return b;
	}
	private static int chmin(int a,int b){
		if(a<b) return a;
		else return b;
	}
} 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();
		System.out.println(getCD(a,b,k));
	} main {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		System.out.println(getCD(a,b,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 System.out.println(getCD(a,b,k)) System.out.println System.out System System.out getCD(a,b,k) getCD a b k String[] args args private static int getCD(int a,int b,int k){
		int n=k;
		for(int i=chmin(a,b);i>0;i--){
			if(a%i==0 && b%i==0){
				n--;
				if(n==0)return i;
			}
		}
		return 0;
	} getCD {
		int n=k;
		for(int i=chmin(a,b);i>0;i--){
			if(a%i==0 && b%i==0){
				n--;
				if(n==0)return i;
			}
		}
		return 0;
	} int n=k; n k for(int i=chmin(a,b);i>0;i--){
			if(a%i==0 && b%i==0){
				n--;
				if(n==0)return i;
			}
		} int i=chmin(a,b); int i=chmin(a,b); i chmin(a,b) chmin a b i>0 i 0 i-- i-- i {
			if(a%i==0 && b%i==0){
				n--;
				if(n==0)return i;
			}
		} {
			if(a%i==0 && b%i==0){
				n--;
				if(n==0)return i;
			}
		} if(a%i==0 && b%i==0){
				n--;
				if(n==0)return i;
			} a%i==0 && b%i==0 a%i==0 a%i a i 0 b%i==0 b%i b i 0 {
				n--;
				if(n==0)return i;
			} n-- n if(n==0)return i; n==0 n 0 return i; i return 0; 0 int a a int b b int k k private static int chmax(int a,int b){
		if(a>b) return a;
		else return b;
	} chmax {
		if(a>b) return a;
		else return b;
	} if(a>b) return a;
		else return b; a>b a b return a; a return b; b int a a int b b private static int chmin(int a,int b){
		if(a<b) return a;
		else return b;
	} chmin {
		if(a<b) return a;
		else return b;
	} if(a<b) return a;
		else return b; a<b a b return a; a return b; b int a a int b b 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();
		System.out.println(getCD(a,b,k));
	}
	private static int getCD(int a,int b,int k){
		int n=k;
		for(int i=chmin(a,b);i>0;i--){
			if(a%i==0 && b%i==0){
				n--;
				if(n==0)return i;
			}
		}
		return 0;
	}
	private static int chmax(int a,int b){
		if(a>b) return a;
		else return b;
	}
	private static int chmin(int a,int b){
		if(a<b) return a;
		else return b;
	}
} 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();
		System.out.println(getCD(a,b,k));
	}
	private static int getCD(int a,int b,int k){
		int n=k;
		for(int i=chmin(a,b);i>0;i--){
			if(a%i==0 && b%i==0){
				n--;
				if(n==0)return i;
			}
		}
		return 0;
	}
	private static int chmax(int a,int b){
		if(a>b) return a;
		else return b;
	}
	private static int chmin(int a,int b){
		if(a<b) return a;
		else return b;
	}
} 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();
		System.out.println(getCD(a,b,k));
	}
	private static int getCD(int a,int b,int k){
		int n=k;
		for(int i=chmin(a,b);i>0;i--){
			if(a%i==0 && b%i==0){
				n--;
				if(n==0)return i;
			}
		}
		return 0;
	}
	private static int chmax(int a,int b){
		if(a>b) return a;
		else return b;
	}
	private static int chmin(int a,int b){
		if(a<b) return a;
		else return b;
	}
}