import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        int a = stdIn.nextInt();
        int b = stdIn.nextInt();
        int k = stdIn.nextInt();
        int count = 0;
        int min;
        int[] num = new int[100];

        if(a>b) min = b;
        else min = a;
        for(int i=1;i<min+1;i++){
            if(a%i==0 && b%i==0) {
                num[count] = i;
                count++;
            }
        }
        System.out.println(num[count-k]);
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        int a = stdIn.nextInt();
        int b = stdIn.nextInt();
        int k = stdIn.nextInt();
        int count = 0;
        int min;
        int[] num = new int[100];

        if(a>b) min = b;
        else min = a;
        for(int i=1;i<min+1;i++){
            if(a%i==0 && b%i==0) {
                num[count] = i;
                count++;
            }
        }
        System.out.println(num[count-k]);
    }
} Main public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        int a = stdIn.nextInt();
        int b = stdIn.nextInt();
        int k = stdIn.nextInt();
        int count = 0;
        int min;
        int[] num = new int[100];

        if(a>b) min = b;
        else min = a;
        for(int i=1;i<min+1;i++){
            if(a%i==0 && b%i==0) {
                num[count] = i;
                count++;
            }
        }
        System.out.println(num[count-k]);
    } main {
        Scanner stdIn = new Scanner(System.in);
        int a = stdIn.nextInt();
        int b = stdIn.nextInt();
        int k = stdIn.nextInt();
        int count = 0;
        int min;
        int[] num = new int[100];

        if(a>b) min = b;
        else min = a;
        for(int i=1;i<min+1;i++){
            if(a%i==0 && b%i==0) {
                num[count] = i;
                count++;
            }
        }
        System.out.println(num[count-k]);
    } Scanner stdIn = new Scanner(System.in); stdIn new Scanner(System.in) int a = stdIn.nextInt(); a stdIn.nextInt() stdIn.nextInt stdIn int b = stdIn.nextInt(); b stdIn.nextInt() stdIn.nextInt stdIn int k = stdIn.nextInt(); k stdIn.nextInt() stdIn.nextInt stdIn int count = 0; count 0 int min; min int[] num = new int[100]; num new int[100] 100 if(a>b) min = b;
        else min = a; a>b a b min = b min b min = a min a for(int i=1;i<min+1;i++){
            if(a%i==0 && b%i==0) {
                num[count] = i;
                count++;
            }
        } int i=1; int i=1; i 1 i<min+1 i min+1 min 1 i++ i++ i {
            if(a%i==0 && b%i==0) {
                num[count] = i;
                count++;
            }
        } {
            if(a%i==0 && b%i==0) {
                num[count] = i;
                count++;
            }
        } if(a%i==0 && b%i==0) {
                num[count] = i;
                count++;
            } a%i==0 && b%i==0 a%i==0 a%i a i 0 b%i==0 b%i b i 0 {
                num[count] = i;
                count++;
            } num[count] = i num[count] num count i count++ count System.out.println(num[count-k]) System.out.println System.out System System.out num[count-k] num count-k count k String[] args args public class Main {
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        int a = stdIn.nextInt();
        int b = stdIn.nextInt();
        int k = stdIn.nextInt();
        int count = 0;
        int min;
        int[] num = new int[100];

        if(a>b) min = b;
        else min = a;
        for(int i=1;i<min+1;i++){
            if(a%i==0 && b%i==0) {
                num[count] = i;
                count++;
            }
        }
        System.out.println(num[count-k]);
    }
} public class Main {
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        int a = stdIn.nextInt();
        int b = stdIn.nextInt();
        int k = stdIn.nextInt();
        int count = 0;
        int min;
        int[] num = new int[100];

        if(a>b) min = b;
        else min = a;
        for(int i=1;i<min+1;i++){
            if(a%i==0 && b%i==0) {
                num[count] = i;
                count++;
            }
        }
        System.out.println(num[count-k]);
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner stdIn = new Scanner(System.in);
        int a = stdIn.nextInt();
        int b = stdIn.nextInt();
        int k = stdIn.nextInt();
        int count = 0;
        int min;
        int[] num = new int[100];

        if(a>b) min = b;
        else min = a;
        for(int i=1;i<min+1;i++){
            if(a%i==0 && b%i==0) {
                num[count] = i;
                count++;
            }
        }
        System.out.println(num[count-k]);
    }
}