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();
        //char[] S = sc.next().toCharArray();
        int count=0;
        int S = Math.min(A, B);
        int L = Math.max(A, B);
        for(int i=S; i>0; i--){
            if(S%i==0 && L%i==0){
                count++;
                if(count==K){
                    System.out.println(i);
                    return;
                }

            }

        }

          //System.out.println(count);
        }
    } 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();
        //char[] S = sc.next().toCharArray();
        int count=0;
        int S = Math.min(A, B);
        int L = Math.max(A, B);
        for(int i=S; i>0; i--){
            if(S%i==0 && L%i==0){
                count++;
                if(count==K){
                    System.out.println(i);
                    return;
                }

            }

        }

          //System.out.println(count);
        }
    } 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();
        //char[] S = sc.next().toCharArray();
        int count=0;
        int S = Math.min(A, B);
        int L = Math.max(A, B);
        for(int i=S; i>0; i--){
            if(S%i==0 && L%i==0){
                count++;
                if(count==K){
                    System.out.println(i);
                    return;
                }

            }

        }

          //System.out.println(count);
        } main {
		Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();
        //char[] S = sc.next().toCharArray();
        int count=0;
        int S = Math.min(A, B);
        int L = Math.max(A, B);
        for(int i=S; i>0; i--){
            if(S%i==0 && L%i==0){
                count++;
                if(count==K){
                    System.out.println(i);
                    return;
                }

            }

        }

          //System.out.println(count);
        } 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 count=0; count 0 int S = Math.min(A, B); S Math.min(A, B) Math.min Math A B int L = Math.max(A, B); L Math.max(A, B) Math.max Math A B for(int i=S; i>0; i--){
            if(S%i==0 && L%i==0){
                count++;
                if(count==K){
                    System.out.println(i);
                    return;
                }

            }

        } int i=S; int i=S; i S i>0 i 0 i-- i-- i {
            if(S%i==0 && L%i==0){
                count++;
                if(count==K){
                    System.out.println(i);
                    return;
                }

            }

        } {
            if(S%i==0 && L%i==0){
                count++;
                if(count==K){
                    System.out.println(i);
                    return;
                }

            }

        } if(S%i==0 && L%i==0){
                count++;
                if(count==K){
                    System.out.println(i);
                    return;
                }

            } S%i==0 && L%i==0 S%i==0 S%i S i 0 L%i==0 L%i L i 0 {
                count++;
                if(count==K){
                    System.out.println(i);
                    return;
                }

            } count++ count if(count==K){
                    System.out.println(i);
                    return;
                } count==K count K {
                    System.out.println(i);
                    return;
                } System.out.println(i) System.out.println System.out System System.out i return; 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();
        //char[] S = sc.next().toCharArray();
        int count=0;
        int S = Math.min(A, B);
        int L = Math.max(A, B);
        for(int i=S; i>0; i--){
            if(S%i==0 && L%i==0){
                count++;
                if(count==K){
                    System.out.println(i);
                    return;
                }

            }

        }

          //System.out.println(count);
        }
    } 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();
        //char[] S = sc.next().toCharArray();
        int count=0;
        int S = Math.min(A, B);
        int L = Math.max(A, B);
        for(int i=S; i>0; i--){
            if(S%i==0 && L%i==0){
                count++;
                if(count==K){
                    System.out.println(i);
                    return;
                }

            }

        }

          //System.out.println(count);
        }
    } 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();
        //char[] S = sc.next().toCharArray();
        int count=0;
        int S = Math.min(A, B);
        int L = Math.max(A, B);
        for(int i=S; i>0; i--){
            if(S%i==0 && L%i==0){
                count++;
                if(count==K){
                    System.out.println(i);
                    return;
                }

            }

        }

          //System.out.println(count);
        }
    }