import java.util.*;
    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 m = 0;
        int c = 0;
        for(int i=100;i>=1;i--){
            if(0==a%i&&0==b%i){
                m++;
                if(m==k){
                    System.out.println(i);
                }
            }
        }
    }
} import java.util.*; util.* java 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 m = 0;
        int c = 0;
        for(int i=100;i>=1;i--){
            if(0==a%i&&0==b%i){
                m++;
                if(m==k){
                    System.out.println(i);
                }
            }
        }
    }
} 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 m = 0;
        int c = 0;
        for(int i=100;i>=1;i--){
            if(0==a%i&&0==b%i){
                m++;
                if(m==k){
                    System.out.println(i);
                }
            }
        }
    } main {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        int m = 0;
        int c = 0;
        for(int i=100;i>=1;i--){
            if(0==a%i&&0==b%i){
                m++;
                if(m==k){
                    System.out.println(i);
                }
            }
        }
    } 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 m = 0; m 0 int c = 0; c 0 for(int i=100;i>=1;i--){
            if(0==a%i&&0==b%i){
                m++;
                if(m==k){
                    System.out.println(i);
                }
            }
        } int i=100; int i=100; i 100 i>=1 i 1 i-- i-- i {
            if(0==a%i&&0==b%i){
                m++;
                if(m==k){
                    System.out.println(i);
                }
            }
        } {
            if(0==a%i&&0==b%i){
                m++;
                if(m==k){
                    System.out.println(i);
                }
            }
        } if(0==a%i&&0==b%i){
                m++;
                if(m==k){
                    System.out.println(i);
                }
            } 0==a%i&&0==b%i 0==a%i 0 a%i a i 0==b%i 0 b%i b i {
                m++;
                if(m==k){
                    System.out.println(i);
                }
            } m++ m if(m==k){
                    System.out.println(i);
                } m==k m k {
                    System.out.println(i);
                } System.out.println(i) System.out.println System.out System System.out i String[] args args
import java.util.*;
    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 m = 0;
        int c = 0;
        for(int i=100;i>=1;i--){
            if(0==a%i&&0==b%i){
                m++;
                if(m==k){
                    System.out.println(i);
                }
            }
        }
    }
}