import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] array = new int[2];
        array[0] = sc.nextInt();
        array[1] = sc.nextInt();
        int k = sc.nextInt();
        Arrays.sort(array);
        int aux = array[0] + 1;
        int cont = 0;

        while (true) {
            if (array[1] % aux == 0 && array[0] % aux == 0) {
                cont++;
                if(cont == k) {
                    break;
                }
            }
            aux--;
        }
        System.out.println(aux);
    }
} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] array = new int[2];
        array[0] = sc.nextInt();
        array[1] = sc.nextInt();
        int k = sc.nextInt();
        Arrays.sort(array);
        int aux = array[0] + 1;
        int cont = 0;

        while (true) {
            if (array[1] % aux == 0 && array[0] % aux == 0) {
                cont++;
                if(cont == k) {
                    break;
                }
            }
            aux--;
        }
        System.out.println(aux);
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] array = new int[2];
        array[0] = sc.nextInt();
        array[1] = sc.nextInt();
        int k = sc.nextInt();
        Arrays.sort(array);
        int aux = array[0] + 1;
        int cont = 0;

        while (true) {
            if (array[1] % aux == 0 && array[0] % aux == 0) {
                cont++;
                if(cont == k) {
                    break;
                }
            }
            aux--;
        }
        System.out.println(aux);
    } main {
        Scanner sc = new Scanner(System.in);
        int[] array = new int[2];
        array[0] = sc.nextInt();
        array[1] = sc.nextInt();
        int k = sc.nextInt();
        Arrays.sort(array);
        int aux = array[0] + 1;
        int cont = 0;

        while (true) {
            if (array[1] % aux == 0 && array[0] % aux == 0) {
                cont++;
                if(cont == k) {
                    break;
                }
            }
            aux--;
        }
        System.out.println(aux);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int[] array = new int[2]; array new int[2] 2 array[0] = sc.nextInt() array[0] array 0 sc.nextInt() sc.nextInt sc array[1] = sc.nextInt() array[1] array 1 sc.nextInt() sc.nextInt sc int k = sc.nextInt(); k sc.nextInt() sc.nextInt sc Arrays.sort(array) Arrays.sort Arrays array int aux = array[0] + 1; aux array[0] + 1 array[0] array 0 1 int cont = 0; cont 0 while (true) {
            if (array[1] % aux == 0 && array[0] % aux == 0) {
                cont++;
                if(cont == k) {
                    break;
                }
            }
            aux--;
        } true {
            if (array[1] % aux == 0 && array[0] % aux == 0) {
                cont++;
                if(cont == k) {
                    break;
                }
            }
            aux--;
        } if (array[1] % aux == 0 && array[0] % aux == 0) {
                cont++;
                if(cont == k) {
                    break;
                }
            } array[1] % aux == 0 && array[0] % aux == 0 array[1] % aux == 0 array[1] % aux array[1] array 1 aux 0 array[0] % aux == 0 array[0] % aux array[0] array 0 aux 0 {
                cont++;
                if(cont == k) {
                    break;
                }
            } cont++ cont if(cont == k) {
                    break;
                } cont == k cont k {
                    break;
                } break; aux-- aux System.out.println(aux) System.out.println System.out System System.out aux String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] array = new int[2];
        array[0] = sc.nextInt();
        array[1] = sc.nextInt();
        int k = sc.nextInt();
        Arrays.sort(array);
        int aux = array[0] + 1;
        int cont = 0;

        while (true) {
            if (array[1] % aux == 0 && array[0] % aux == 0) {
                cont++;
                if(cont == k) {
                    break;
                }
            }
            aux--;
        }
        System.out.println(aux);
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] array = new int[2];
        array[0] = sc.nextInt();
        array[1] = sc.nextInt();
        int k = sc.nextInt();
        Arrays.sort(array);
        int aux = array[0] + 1;
        int cont = 0;

        while (true) {
            if (array[1] % aux == 0 && array[0] % aux == 0) {
                cont++;
                if(cont == k) {
                    break;
                }
            }
            aux--;
        }
        System.out.println(aux);
    }
} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int[] array = new int[2];
        array[0] = sc.nextInt();
        array[1] = sc.nextInt();
        int k = sc.nextInt();
        Arrays.sort(array);
        int aux = array[0] + 1;
        int cont = 0;

        while (true) {
            if (array[1] % aux == 0 && array[0] % aux == 0) {
                cont++;
                if(cont == k) {
                    break;
                }
            }
            aux--;
        }
        System.out.println(aux);
    }
}