
import java.util.Scanner;

public class Main {

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

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

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

    public static void main(String[] args) {
        Scanner t = new Scanner(System.in);
        
        int a = t.nextInt();
        int b = t.nextInt();
        int k = t.nextInt();
        int i;
        int s = 0, menor;
        if (a<=b){
            menor = a;
        } else {
            menor = b;
        }
        for (i = menor; i >= 1; i--) {
            if (a % i == 0 && b % i == 0){
                s++;
            }
            if (s == k){
                System.out.println(i);
                break;
            }
        }
    }   
} Main

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner t = new Scanner(System.in);
        
        int a = t.nextInt();
        int b = t.nextInt();
        int k = t.nextInt();
        int i;
        int s = 0, menor;
        if (a<=b){
            menor = a;
        } else {
            menor = b;
        }
        for (i = menor; i >= 1; i--) {
            if (a % i == 0 && b % i == 0){
                s++;
            }
            if (s == k){
                System.out.println(i);
                break;
            }
        }
    }   
}