import java.util.Scanner;

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 times = 0;
		int max = Math.max(A, B);
		int output = max;
		for(int i = max; i >= 1; i--) {
			if(A%i == 0 && B%i == 0) {
				times++;
				output = i;
				if(times == K) {					
					break;
				}
			}
		}
		System.out.println(output);	
	}
} import java.util.Scanner; Scanner 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 times = 0;
		int max = Math.max(A, B);
		int output = max;
		for(int i = max; i >= 1; i--) {
			if(A%i == 0 && B%i == 0) {
				times++;
				output = i;
				if(times == K) {					
					break;
				}
			}
		}
		System.out.println(output);	
	}
} 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 times = 0;
		int max = Math.max(A, B);
		int output = max;
		for(int i = max; i >= 1; i--) {
			if(A%i == 0 && B%i == 0) {
				times++;
				output = i;
				if(times == K) {					
					break;
				}
			}
		}
		System.out.println(output);	
	} main {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int K = sc.nextInt();
		
		int times = 0;
		int max = Math.max(A, B);
		int output = max;
		for(int i = max; i >= 1; i--) {
			if(A%i == 0 && B%i == 0) {
				times++;
				output = i;
				if(times == K) {					
					break;
				}
			}
		}
		System.out.println(output);	
	} 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 times = 0; times 0 int max = Math.max(A, B); max Math.max(A, B) Math.max Math A B int output = max; output max for(int i = max; i >= 1; i--) {
			if(A%i == 0 && B%i == 0) {
				times++;
				output = i;
				if(times == K) {					
					break;
				}
			}
		} int i = max; int i = max; i max i >= 1 i 1 i-- i-- i {
			if(A%i == 0 && B%i == 0) {
				times++;
				output = i;
				if(times == K) {					
					break;
				}
			}
		} {
			if(A%i == 0 && B%i == 0) {
				times++;
				output = i;
				if(times == K) {					
					break;
				}
			}
		} if(A%i == 0 && B%i == 0) {
				times++;
				output = i;
				if(times == K) {					
					break;
				}
			} A%i == 0 && B%i == 0 A%i == 0 A%i A i 0 B%i == 0 B%i B i 0 {
				times++;
				output = i;
				if(times == K) {					
					break;
				}
			} times++ times output = i output i if(times == K) {					
					break;
				} times == K times K {					
					break;
				} break; System.out.println(output) System.out.println System.out System System.out output 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 times = 0;
		int max = Math.max(A, B);
		int output = max;
		for(int i = max; i >= 1; i--) {
			if(A%i == 0 && B%i == 0) {
				times++;
				output = i;
				if(times == K) {					
					break;
				}
			}
		}
		System.out.println(output);	
	}
} 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 times = 0;
		int max = Math.max(A, B);
		int output = max;
		for(int i = max; i >= 1; i--) {
			if(A%i == 0 && B%i == 0) {
				times++;
				output = i;
				if(times == K) {					
					break;
				}
			}
		}
		System.out.println(output);	
	}
} Main
import java.util.Scanner;

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 times = 0;
		int max = Math.max(A, B);
		int output = max;
		for(int i = max; i >= 1; i--) {
			if(A%i == 0 && B%i == 0) {
				times++;
				output = i;
				if(times == K) {					
					break;
				}
			}
		}
		System.out.println(output);	
	}
}
