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 N = Math.max(A, B);
		int count=0;
		int kekka=0;
		
		for(int i=(Math.min(A, B));i>=1;i--) {
			if(A%i==0 && B%i==0) {
				count++;
				if(count==K) {
					kekka=i;
					break;
				}
			}
		}
		
		System.out.println(kekka);
		
		
		
		sc.close();
	}
} 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 N = Math.max(A, B);
		int count=0;
		int kekka=0;
		
		for(int i=(Math.min(A, B));i>=1;i--) {
			if(A%i==0 && B%i==0) {
				count++;
				if(count==K) {
					kekka=i;
					break;
				}
			}
		}
		
		System.out.println(kekka);
		
		
		
		sc.close();
	}
} 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.max(A, B);
		int count=0;
		int kekka=0;
		
		for(int i=(Math.min(A, B));i>=1;i--) {
			if(A%i==0 && B%i==0) {
				count++;
				if(count==K) {
					kekka=i;
					break;
				}
			}
		}
		
		System.out.println(kekka);
		
		
		
		sc.close();
	} main {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int K = sc.nextInt();
		int N = Math.max(A, B);
		int count=0;
		int kekka=0;
		
		for(int i=(Math.min(A, B));i>=1;i--) {
			if(A%i==0 && B%i==0) {
				count++;
				if(count==K) {
					kekka=i;
					break;
				}
			}
		}
		
		System.out.println(kekka);
		
		
		
		sc.close();
	} 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.max(A, B); N Math.max(A, B) Math.max Math A B int count=0; count 0 int kekka=0; kekka 0 for(int i=(Math.min(A, B));i>=1;i--) {
			if(A%i==0 && B%i==0) {
				count++;
				if(count==K) {
					kekka=i;
					break;
				}
			}
		} int i=(Math.min(A, B)); int i=(Math.min(A, B)); i (Math.min(A, B)) Math.min Math A B i>=1 i 1 i-- i-- i {
			if(A%i==0 && B%i==0) {
				count++;
				if(count==K) {
					kekka=i;
					break;
				}
			}
		} {
			if(A%i==0 && B%i==0) {
				count++;
				if(count==K) {
					kekka=i;
					break;
				}
			}
		} if(A%i==0 && B%i==0) {
				count++;
				if(count==K) {
					kekka=i;
					break;
				}
			} A%i==0 && B%i==0 A%i==0 A%i A i 0 B%i==0 B%i B i 0 {
				count++;
				if(count==K) {
					kekka=i;
					break;
				}
			} count++ count if(count==K) {
					kekka=i;
					break;
				} count==K count K {
					kekka=i;
					break;
				} kekka=i kekka i break; System.out.println(kekka) System.out.println System.out System System.out kekka sc.close() sc.close sc 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.max(A, B);
		int count=0;
		int kekka=0;
		
		for(int i=(Math.min(A, B));i>=1;i--) {
			if(A%i==0 && B%i==0) {
				count++;
				if(count==K) {
					kekka=i;
					break;
				}
			}
		}
		
		System.out.println(kekka);
		
		
		
		sc.close();
	}
} 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.max(A, B);
		int count=0;
		int kekka=0;
		
		for(int i=(Math.min(A, B));i>=1;i--) {
			if(A%i==0 && B%i==0) {
				count++;
				if(count==K) {
					kekka=i;
					break;
				}
			}
		}
		
		System.out.println(kekka);
		
		
		
		sc.close();
	}
} 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 N = Math.max(A, B);
		int count=0;
		int kekka=0;
		
		for(int i=(Math.min(A, B));i>=1;i--) {
			if(A%i==0 && B%i==0) {
				count++;
				if(count==K) {
					kekka=i;
					break;
				}
			}
		}
		
		System.out.println(kekka);
		
		
		
		sc.close();
	}
}
