import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;


public 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 i = 1;
        List<Integer> integers = new ArrayList<>();

        while (i <= a || i <= b) {
            if (a % i == 0 && b % i == 0) {
                integers.add(i);
            }
            i++;
        }
        System.out.println(integers.get(integers.size() - k));
    }
}
 import java.util.ArrayList; ArrayList java.util import java.util.Arrays; Arrays java.util import java.util.List; List 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 a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        int i = 1;
        List<Integer> integers = new ArrayList<>();

        while (i <= a || i <= b) {
            if (a % i == 0 && b % i == 0) {
                integers.add(i);
            }
            i++;
        }
        System.out.println(integers.get(integers.size() - k));
    }
} 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 i = 1;
        List<Integer> integers = new ArrayList<>();

        while (i <= a || i <= b) {
            if (a % i == 0 && b % i == 0) {
                integers.add(i);
            }
            i++;
        }
        System.out.println(integers.get(integers.size() - k));
    } main {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        int i = 1;
        List<Integer> integers = new ArrayList<>();

        while (i <= a || i <= b) {
            if (a % i == 0 && b % i == 0) {
                integers.add(i);
            }
            i++;
        }
        System.out.println(integers.get(integers.size() - k));
    } 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 i = 1; i 1 List<Integer> integers = new ArrayList<>(); integers new ArrayList<>() while (i <= a || i <= b) {
            if (a % i == 0 && b % i == 0) {
                integers.add(i);
            }
            i++;
        } i <= a || i <= b i <= a i a i <= b i b {
            if (a % i == 0 && b % i == 0) {
                integers.add(i);
            }
            i++;
        } if (a % i == 0 && b % i == 0) {
                integers.add(i);
            } a % i == 0 && b % i == 0 a % i == 0 a % i a i 0 b % i == 0 b % i b i 0 {
                integers.add(i);
            } integers.add(i) integers.add integers i i++ i System.out.println(integers.get(integers.size() - k)) System.out.println System.out System System.out integers.get(integers.size() - k) integers.get integers integers.size() - k integers.size() integers.size integers k String[] args args public 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 i = 1;
        List<Integer> integers = new ArrayList<>();

        while (i <= a || i <= b) {
            if (a % i == 0 && b % i == 0) {
                integers.add(i);
            }
            i++;
        }
        System.out.println(integers.get(integers.size() - k));
    }
} public 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 i = 1;
        List<Integer> integers = new ArrayList<>();

        while (i <= a || i <= b) {
            if (a % i == 0 && b % i == 0) {
                integers.add(i);
            }
            i++;
        }
        System.out.println(integers.get(integers.size() - k));
    }
} Main
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;


public 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 i = 1;
        List<Integer> integers = new ArrayList<>();

        while (i <= a || i <= b) {
            if (a % i == 0 && b % i == 0) {
                integers.add(i);
            }
            i++;
        }
        System.out.println(integers.get(integers.size() - k));
    }
}

