

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 n = Math.min(a, b);
		int ans = 0;
		sc.close();
		
		for(int i = n; i >= 1; i--){
			if(a % i == 0 && b % i == 0) {
				k--;
				ans = i;
				
				if(k == 0) {
					break;
				}
			}
		}
		System.out.println(ans);
	}
} 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 n = Math.min(a, b);
		int ans = 0;
		sc.close();
		
		for(int i = n; i >= 1; i--){
			if(a % i == 0 && b % i == 0) {
				k--;
				ans = i;
				
				if(k == 0) {
					break;
				}
			}
		}
		System.out.println(ans);
	}
} 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 n = Math.min(a, b);
		int ans = 0;
		sc.close();
		
		for(int i = n; i >= 1; i--){
			if(a % i == 0 && b % i == 0) {
				k--;
				ans = i;
				
				if(k == 0) {
					break;
				}
			}
		}
		System.out.println(ans);
	} main {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		int n = Math.min(a, b);
		int ans = 0;
		sc.close();
		
		for(int i = n; i >= 1; i--){
			if(a % i == 0 && b % i == 0) {
				k--;
				ans = i;
				
				if(k == 0) {
					break;
				}
			}
		}
		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 n = Math.min(a, b); n Math.min(a, b) Math.min Math a b int ans = 0; ans 0 sc.close() sc.close sc for(int i = n; i >= 1; i--){
			if(a % i == 0 && b % i == 0) {
				k--;
				ans = i;
				
				if(k == 0) {
					break;
				}
			}
		} int i = n; int i = n; i n i >= 1 i 1 i-- i-- i {
			if(a % i == 0 && b % i == 0) {
				k--;
				ans = i;
				
				if(k == 0) {
					break;
				}
			}
		} {
			if(a % i == 0 && b % i == 0) {
				k--;
				ans = i;
				
				if(k == 0) {
					break;
				}
			}
		} if(a % i == 0 && b % i == 0) {
				k--;
				ans = i;
				
				if(k == 0) {
					break;
				}
			} a % i == 0 && b % i == 0 a % i == 0 a % i a i 0 b % i == 0 b % i b i 0 {
				k--;
				ans = i;
				
				if(k == 0) {
					break;
				}
			} k-- k ans = i ans i if(k == 0) {
					break;
				} k == 0 k 0 {
					break;
				} break; System.out.println(ans) System.out.println System.out System System.out ans 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 n = Math.min(a, b);
		int ans = 0;
		sc.close();
		
		for(int i = n; i >= 1; i--){
			if(a % i == 0 && b % i == 0) {
				k--;
				ans = i;
				
				if(k == 0) {
					break;
				}
			}
		}
		System.out.println(ans);
	}
} 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 n = Math.min(a, b);
		int ans = 0;
		sc.close();
		
		for(int i = n; i >= 1; i--){
			if(a % i == 0 && b % i == 0) {
				k--;
				ans = i;
				
				if(k == 0) {
					break;
				}
			}
		}
		System.out.println(ans);
	}
} 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 n = Math.min(a, b);
		int ans = 0;
		sc.close();
		
		for(int i = n; i >= 1; i--){
			if(a % i == 0 && b % i == 0) {
				k--;
				ans = i;
				
				if(k == 0) {
					break;
				}
			}
		}
		System.out.println(ans);
	}
}
