import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner s = new Scanner(System.in);

        int a = Integer.parseInt(s.next());
        int b = Integer.parseInt(s.next());
        int k = Integer.parseInt(s.next());

        int min = a < b ? a : b;
        List<Integer> list = new ArrayList<Integer>();
        for (int i = 1; i <= min; i++) {
            if (a % i == 0 && b % i == 0) {
                list.add(i);
            }
        }
        Optional<Integer> an = list.stream()
                .sorted(Comparator.reverseOrder())
                .skip(k - 1)
                .findFirst();

        System.out.println(an.orElse(0));
    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {

        Scanner s = new Scanner(System.in);

        int a = Integer.parseInt(s.next());
        int b = Integer.parseInt(s.next());
        int k = Integer.parseInt(s.next());

        int min = a < b ? a : b;
        List<Integer> list = new ArrayList<Integer>();
        for (int i = 1; i <= min; i++) {
            if (a % i == 0 && b % i == 0) {
                list.add(i);
            }
        }
        Optional<Integer> an = list.stream()
                .sorted(Comparator.reverseOrder())
                .skip(k - 1)
                .findFirst();

        System.out.println(an.orElse(0));
    }
} Main public static void main(String[] args) {

        Scanner s = new Scanner(System.in);

        int a = Integer.parseInt(s.next());
        int b = Integer.parseInt(s.next());
        int k = Integer.parseInt(s.next());

        int min = a < b ? a : b;
        List<Integer> list = new ArrayList<Integer>();
        for (int i = 1; i <= min; i++) {
            if (a % i == 0 && b % i == 0) {
                list.add(i);
            }
        }
        Optional<Integer> an = list.stream()
                .sorted(Comparator.reverseOrder())
                .skip(k - 1)
                .findFirst();

        System.out.println(an.orElse(0));
    } main {

        Scanner s = new Scanner(System.in);

        int a = Integer.parseInt(s.next());
        int b = Integer.parseInt(s.next());
        int k = Integer.parseInt(s.next());

        int min = a < b ? a : b;
        List<Integer> list = new ArrayList<Integer>();
        for (int i = 1; i <= min; i++) {
            if (a % i == 0 && b % i == 0) {
                list.add(i);
            }
        }
        Optional<Integer> an = list.stream()
                .sorted(Comparator.reverseOrder())
                .skip(k - 1)
                .findFirst();

        System.out.println(an.orElse(0));
    } Scanner s = new Scanner(System.in); s new Scanner(System.in) int a = Integer.parseInt(s.next()); a Integer.parseInt(s.next()) Integer.parseInt Integer s.next() s.next s int b = Integer.parseInt(s.next()); b Integer.parseInt(s.next()) Integer.parseInt Integer s.next() s.next s int k = Integer.parseInt(s.next()); k Integer.parseInt(s.next()) Integer.parseInt Integer s.next() s.next s int min = a < b ? a : b; min a < b ? a : b a < b a b a b List<Integer> list = new ArrayList<Integer>(); list new ArrayList<Integer>() for (int i = 1; i <= min; i++) {
            if (a % i == 0 && b % i == 0) {
                list.add(i);
            }
        } int i = 1; int i = 1; i 1 i <= min i min i++ i++ i {
            if (a % i == 0 && b % i == 0) {
                list.add(i);
            }
        } {
            if (a % i == 0 && b % i == 0) {
                list.add(i);
            }
        } if (a % i == 0 && b % i == 0) {
                list.add(i);
            } a % i == 0 && b % i == 0 a % i == 0 a % i a i 0 b % i == 0 b % i b i 0 {
                list.add(i);
            } list.add(i) list.add list i Optional<Integer> an = list.stream()
                .sorted(Comparator.reverseOrder())
                .skip(k - 1)
                .findFirst(); an list.stream()
                .sorted(Comparator.reverseOrder())
                .skip(k - 1)
                .findFirst() list.stream()
                .sorted(Comparator.reverseOrder())
                .skip(k - 1)
                .findFirst list.stream()
                .sorted(Comparator.reverseOrder())
                .skip(k - 1) list.stream()
                .sorted(Comparator.reverseOrder())
                .skip list.stream()
                .sorted(Comparator.reverseOrder()) list.stream()
                .sorted list.stream() list.stream list Comparator.reverseOrder() Comparator.reverseOrder Comparator k - 1 k 1 System.out.println(an.orElse(0)) System.out.println System.out System System.out an.orElse(0) an.orElse an 0 String[] args args public class Main {
    public static void main(String[] args) {

        Scanner s = new Scanner(System.in);

        int a = Integer.parseInt(s.next());
        int b = Integer.parseInt(s.next());
        int k = Integer.parseInt(s.next());

        int min = a < b ? a : b;
        List<Integer> list = new ArrayList<Integer>();
        for (int i = 1; i <= min; i++) {
            if (a % i == 0 && b % i == 0) {
                list.add(i);
            }
        }
        Optional<Integer> an = list.stream()
                .sorted(Comparator.reverseOrder())
                .skip(k - 1)
                .findFirst();

        System.out.println(an.orElse(0));
    }
} public class Main {
    public static void main(String[] args) {

        Scanner s = new Scanner(System.in);

        int a = Integer.parseInt(s.next());
        int b = Integer.parseInt(s.next());
        int k = Integer.parseInt(s.next());

        int min = a < b ? a : b;
        List<Integer> list = new ArrayList<Integer>();
        for (int i = 1; i <= min; i++) {
            if (a % i == 0 && b % i == 0) {
                list.add(i);
            }
        }
        Optional<Integer> an = list.stream()
                .sorted(Comparator.reverseOrder())
                .skip(k - 1)
                .findFirst();

        System.out.println(an.orElse(0));
    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner s = new Scanner(System.in);

        int a = Integer.parseInt(s.next());
        int b = Integer.parseInt(s.next());
        int k = Integer.parseInt(s.next());

        int min = a < b ? a : b;
        List<Integer> list = new ArrayList<Integer>();
        for (int i = 1; i <= min; i++) {
            if (a % i == 0 && b % i == 0) {
                list.add(i);
            }
        }
        Optional<Integer> an = list.stream()
                .sorted(Comparator.reverseOrder())
                .skip(k - 1)
                .findFirst();

        System.out.println(an.orElse(0));
    }
}