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();
		int x[]=new int[B];
		int y=0;
		
		for(int i=1;i<=B;i++) {
			if(A%i==0&&B%i==0) {
				x[y]=i;
				y++;
				
			}
			
		}
		System.out.println(x[y-K]);
}
} 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();
		int x[]=new int[B];
		int y=0;
		
		for(int i=1;i<=B;i++) {
			if(A%i==0&&B%i==0) {
				x[y]=i;
				y++;
				
			}
			
		}
		System.out.println(x[y-K]);
}
} 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();
		int x[]=new int[B];
		int y=0;
		
		for(int i=1;i<=B;i++) {
			if(A%i==0&&B%i==0) {
				x[y]=i;
				y++;
				
			}
			
		}
		System.out.println(x[y-K]);
} main {
		Scanner sc=new Scanner(System.in);
		int A=sc.nextInt();
		int B=sc.nextInt();
		int K=sc.nextInt();
		int x[]=new int[B];
		int y=0;
		
		for(int i=1;i<=B;i++) {
			if(A%i==0&&B%i==0) {
				x[y]=i;
				y++;
				
			}
			
		}
		System.out.println(x[y-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 int x[]=new int[B]; x new int[B] B int y=0; y 0 for(int i=1;i<=B;i++) {
			if(A%i==0&&B%i==0) {
				x[y]=i;
				y++;
				
			}
			
		} int i=1; int i=1; i 1 i<=B i B i++ i++ i {
			if(A%i==0&&B%i==0) {
				x[y]=i;
				y++;
				
			}
			
		} {
			if(A%i==0&&B%i==0) {
				x[y]=i;
				y++;
				
			}
			
		} if(A%i==0&&B%i==0) {
				x[y]=i;
				y++;
				
			} A%i==0&&B%i==0 A%i==0 A%i A i 0 B%i==0 B%i B i 0 {
				x[y]=i;
				y++;
				
			} x[y]=i x[y] x y i y++ y System.out.println(x[y-K]) System.out.println System.out System System.out x[y-K] x y-K y K String[] args args 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();
		int x[]=new int[B];
		int y=0;
		
		for(int i=1;i<=B;i++) {
			if(A%i==0&&B%i==0) {
				x[y]=i;
				y++;
				
			}
			
		}
		System.out.println(x[y-K]);
}
} 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();
		int x[]=new int[B];
		int y=0;
		
		for(int i=1;i<=B;i++) {
			if(A%i==0&&B%i==0) {
				x[y]=i;
				y++;
				
			}
			
		}
		System.out.println(x[y-K]);
}
} 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();
		int x[]=new int[B];
		int y=0;
		
		for(int i=1;i<=B;i++) {
			if(A%i==0&&B%i==0) {
				x[y]=i;
				y++;
				
			}
			
		}
		System.out.println(x[y-K]);
}
}