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

		int a = sc.nextInt();	//A
		int b = sc.nextInt();	//B
		int k = sc.nextInt();	//K
		int[] aS = new int[a];

		int aScnt = 0;
		for(int x=1;x<=a;x++){
			if(a%x==0){
				aS[aScnt] = x;
				aScnt++;
			}
		}
		aScnt--;
		int ans = 0;
		for(int x=b;x>0;x--){
			while(aS[aScnt]>x){
				aScnt--;
			}
			if(b%x==0&&aS[aScnt]==x){
				ans++;
				if(ans==k)break;
			}
		}
		System.out.println(aS[aScnt]);
	}
} import java.util.*; util.* java public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();	//A
		int b = sc.nextInt();	//B
		int k = sc.nextInt();	//K
		int[] aS = new int[a];

		int aScnt = 0;
		for(int x=1;x<=a;x++){
			if(a%x==0){
				aS[aScnt] = x;
				aScnt++;
			}
		}
		aScnt--;
		int ans = 0;
		for(int x=b;x>0;x--){
			while(aS[aScnt]>x){
				aScnt--;
			}
			if(b%x==0&&aS[aScnt]==x){
				ans++;
				if(ans==k)break;
			}
		}
		System.out.println(aS[aScnt]);
	}
} Main public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();	//A
		int b = sc.nextInt();	//B
		int k = sc.nextInt();	//K
		int[] aS = new int[a];

		int aScnt = 0;
		for(int x=1;x<=a;x++){
			if(a%x==0){
				aS[aScnt] = x;
				aScnt++;
			}
		}
		aScnt--;
		int ans = 0;
		for(int x=b;x>0;x--){
			while(aS[aScnt]>x){
				aScnt--;
			}
			if(b%x==0&&aS[aScnt]==x){
				ans++;
				if(ans==k)break;
			}
		}
		System.out.println(aS[aScnt]);
	} main {
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();	//A
		int b = sc.nextInt();	//B
		int k = sc.nextInt();	//K
		int[] aS = new int[a];

		int aScnt = 0;
		for(int x=1;x<=a;x++){
			if(a%x==0){
				aS[aScnt] = x;
				aScnt++;
			}
		}
		aScnt--;
		int ans = 0;
		for(int x=b;x>0;x--){
			while(aS[aScnt]>x){
				aScnt--;
			}
			if(b%x==0&&aS[aScnt]==x){
				ans++;
				if(ans==k)break;
			}
		}
		System.out.println(aS[aScnt]);
	} 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[] aS = new int[a]; aS new int[a] a int aScnt = 0; aScnt 0 for(int x=1;x<=a;x++){
			if(a%x==0){
				aS[aScnt] = x;
				aScnt++;
			}
		} int x=1; int x=1; x 1 x<=a x a x++ x++ x {
			if(a%x==0){
				aS[aScnt] = x;
				aScnt++;
			}
		} {
			if(a%x==0){
				aS[aScnt] = x;
				aScnt++;
			}
		} if(a%x==0){
				aS[aScnt] = x;
				aScnt++;
			} a%x==0 a%x a x 0 {
				aS[aScnt] = x;
				aScnt++;
			} aS[aScnt] = x aS[aScnt] aS aScnt x aScnt++ aScnt aScnt-- aScnt int ans = 0; ans 0 for(int x=b;x>0;x--){
			while(aS[aScnt]>x){
				aScnt--;
			}
			if(b%x==0&&aS[aScnt]==x){
				ans++;
				if(ans==k)break;
			}
		} int x=b; int x=b; x b x>0 x 0 x-- x-- x {
			while(aS[aScnt]>x){
				aScnt--;
			}
			if(b%x==0&&aS[aScnt]==x){
				ans++;
				if(ans==k)break;
			}
		} {
			while(aS[aScnt]>x){
				aScnt--;
			}
			if(b%x==0&&aS[aScnt]==x){
				ans++;
				if(ans==k)break;
			}
		} while(aS[aScnt]>x){
				aScnt--;
			} aS[aScnt]>x aS[aScnt] aS aScnt x {
				aScnt--;
			} aScnt-- aScnt if(b%x==0&&aS[aScnt]==x){
				ans++;
				if(ans==k)break;
			} b%x==0&&aS[aScnt]==x b%x==0 b%x b x 0 aS[aScnt]==x aS[aScnt] aS aScnt x {
				ans++;
				if(ans==k)break;
			} ans++ ans if(ans==k)break; ans==k ans k break; System.out.println(aS[aScnt]) System.out.println System.out System System.out aS[aScnt] aS aScnt String[] args args public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();	//A
		int b = sc.nextInt();	//B
		int k = sc.nextInt();	//K
		int[] aS = new int[a];

		int aScnt = 0;
		for(int x=1;x<=a;x++){
			if(a%x==0){
				aS[aScnt] = x;
				aScnt++;
			}
		}
		aScnt--;
		int ans = 0;
		for(int x=b;x>0;x--){
			while(aS[aScnt]>x){
				aScnt--;
			}
			if(b%x==0&&aS[aScnt]==x){
				ans++;
				if(ans==k)break;
			}
		}
		System.out.println(aS[aScnt]);
	}
} public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();	//A
		int b = sc.nextInt();	//B
		int k = sc.nextInt();	//K
		int[] aS = new int[a];

		int aScnt = 0;
		for(int x=1;x<=a;x++){
			if(a%x==0){
				aS[aScnt] = x;
				aScnt++;
			}
		}
		aScnt--;
		int ans = 0;
		for(int x=b;x>0;x--){
			while(aS[aScnt]>x){
				aScnt--;
			}
			if(b%x==0&&aS[aScnt]==x){
				ans++;
				if(ans==k)break;
			}
		}
		System.out.println(aS[aScnt]);
	}
} Main
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();	//A
		int b = sc.nextInt();	//B
		int k = sc.nextInt();	//K
		int[] aS = new int[a];

		int aScnt = 0;
		for(int x=1;x<=a;x++){
			if(a%x==0){
				aS[aScnt] = x;
				aScnt++;
			}
		}
		aScnt--;
		int ans = 0;
		for(int x=b;x>0;x--){
			while(aS[aScnt]>x){
				aScnt--;
			}
			if(b%x==0&&aS[aScnt]==x){
				ans++;
				if(ans==k)break;
			}
		}
		System.out.println(aS[aScnt]);
	}
}