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

public class Main {
    public static void main(String[] args) {
        int x,y,z;
        Scanner sc = new Scanner(System.in);
        List<Integer> divisors = new ArrayList<Integer>();


        String temp = sc.nextLine();
        String[] tempArr = temp.split(" ");

        if (tempArr.length > 2) {
            x = Integer.parseInt(tempArr[0]);
            y = Integer.parseInt(tempArr[1]);
            z = Integer.parseInt(tempArr[2]);
        } else {
            x = 1;
            y = 1;
            z = 1;
        }

        int maxDivisor = 1;
        if (x > y) {
            maxDivisor = x;
        } else if (x < y){
            maxDivisor = y;
        } else {
            maxDivisor = x;
        }



        for (int i = 1; i <= maxDivisor; i++) {
            if ((x % i) == 0 && (y % i) == 0) {
                divisors.add(i);
            }
        }

        System.out.println(divisors.get(divisors.size() - z));

    }
} import java.util.ArrayList; ArrayList 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) {
        int x,y,z;
        Scanner sc = new Scanner(System.in);
        List<Integer> divisors = new ArrayList<Integer>();


        String temp = sc.nextLine();
        String[] tempArr = temp.split(" ");

        if (tempArr.length > 2) {
            x = Integer.parseInt(tempArr[0]);
            y = Integer.parseInt(tempArr[1]);
            z = Integer.parseInt(tempArr[2]);
        } else {
            x = 1;
            y = 1;
            z = 1;
        }

        int maxDivisor = 1;
        if (x > y) {
            maxDivisor = x;
        } else if (x < y){
            maxDivisor = y;
        } else {
            maxDivisor = x;
        }



        for (int i = 1; i <= maxDivisor; i++) {
            if ((x % i) == 0 && (y % i) == 0) {
                divisors.add(i);
            }
        }

        System.out.println(divisors.get(divisors.size() - z));

    }
} Main public static void main(String[] args) {
        int x,y,z;
        Scanner sc = new Scanner(System.in);
        List<Integer> divisors = new ArrayList<Integer>();


        String temp = sc.nextLine();
        String[] tempArr = temp.split(" ");

        if (tempArr.length > 2) {
            x = Integer.parseInt(tempArr[0]);
            y = Integer.parseInt(tempArr[1]);
            z = Integer.parseInt(tempArr[2]);
        } else {
            x = 1;
            y = 1;
            z = 1;
        }

        int maxDivisor = 1;
        if (x > y) {
            maxDivisor = x;
        } else if (x < y){
            maxDivisor = y;
        } else {
            maxDivisor = x;
        }



        for (int i = 1; i <= maxDivisor; i++) {
            if ((x % i) == 0 && (y % i) == 0) {
                divisors.add(i);
            }
        }

        System.out.println(divisors.get(divisors.size() - z));

    } main {
        int x,y,z;
        Scanner sc = new Scanner(System.in);
        List<Integer> divisors = new ArrayList<Integer>();


        String temp = sc.nextLine();
        String[] tempArr = temp.split(" ");

        if (tempArr.length > 2) {
            x = Integer.parseInt(tempArr[0]);
            y = Integer.parseInt(tempArr[1]);
            z = Integer.parseInt(tempArr[2]);
        } else {
            x = 1;
            y = 1;
            z = 1;
        }

        int maxDivisor = 1;
        if (x > y) {
            maxDivisor = x;
        } else if (x < y){
            maxDivisor = y;
        } else {
            maxDivisor = x;
        }



        for (int i = 1; i <= maxDivisor; i++) {
            if ((x % i) == 0 && (y % i) == 0) {
                divisors.add(i);
            }
        }

        System.out.println(divisors.get(divisors.size() - z));

    } int x x y y z; z Scanner sc = new Scanner(System.in); sc new Scanner(System.in) List<Integer> divisors = new ArrayList<Integer>(); divisors new ArrayList<Integer>() String temp = sc.nextLine(); temp sc.nextLine() sc.nextLine sc String[] tempArr = temp.split(" "); tempArr temp.split(" ") temp.split temp " " if (tempArr.length > 2) {
            x = Integer.parseInt(tempArr[0]);
            y = Integer.parseInt(tempArr[1]);
            z = Integer.parseInt(tempArr[2]);
        } else {
            x = 1;
            y = 1;
            z = 1;
        } tempArr.length > 2 tempArr.length tempArr tempArr.length 2 {
            x = Integer.parseInt(tempArr[0]);
            y = Integer.parseInt(tempArr[1]);
            z = Integer.parseInt(tempArr[2]);
        } x = Integer.parseInt(tempArr[0]) x Integer.parseInt(tempArr[0]) Integer.parseInt Integer tempArr[0] tempArr 0 y = Integer.parseInt(tempArr[1]) y Integer.parseInt(tempArr[1]) Integer.parseInt Integer tempArr[1] tempArr 1 z = Integer.parseInt(tempArr[2]) z Integer.parseInt(tempArr[2]) Integer.parseInt Integer tempArr[2] tempArr 2 {
            x = 1;
            y = 1;
            z = 1;
        } x = 1 x 1 y = 1 y 1 z = 1 z 1 int maxDivisor = 1; maxDivisor 1 if (x > y) {
            maxDivisor = x;
        } else if (x < y){
            maxDivisor = y;
        } else {
            maxDivisor = x;
        } x > y x y {
            maxDivisor = x;
        } maxDivisor = x maxDivisor x if (x < y){
            maxDivisor = y;
        } else {
            maxDivisor = x;
        } x < y x y {
            maxDivisor = y;
        } maxDivisor = y maxDivisor y {
            maxDivisor = x;
        } maxDivisor = x maxDivisor x for (int i = 1; i <= maxDivisor; i++) {
            if ((x % i) == 0 && (y % i) == 0) {
                divisors.add(i);
            }
        } int i = 1; int i = 1; i 1 i <= maxDivisor i maxDivisor i++ i++ i {
            if ((x % i) == 0 && (y % i) == 0) {
                divisors.add(i);
            }
        } {
            if ((x % i) == 0 && (y % i) == 0) {
                divisors.add(i);
            }
        } if ((x % i) == 0 && (y % i) == 0) {
                divisors.add(i);
            } (x % i) == 0 && (y % i) == 0 (x % i) == 0 (x % i) x i 0 (y % i) == 0 (y % i) y i 0 {
                divisors.add(i);
            } divisors.add(i) divisors.add divisors i System.out.println(divisors.get(divisors.size() - z)) System.out.println System.out System System.out divisors.get(divisors.size() - z) divisors.get divisors divisors.size() - z divisors.size() divisors.size divisors z String[] args args public class Main {
    public static void main(String[] args) {
        int x,y,z;
        Scanner sc = new Scanner(System.in);
        List<Integer> divisors = new ArrayList<Integer>();


        String temp = sc.nextLine();
        String[] tempArr = temp.split(" ");

        if (tempArr.length > 2) {
            x = Integer.parseInt(tempArr[0]);
            y = Integer.parseInt(tempArr[1]);
            z = Integer.parseInt(tempArr[2]);
        } else {
            x = 1;
            y = 1;
            z = 1;
        }

        int maxDivisor = 1;
        if (x > y) {
            maxDivisor = x;
        } else if (x < y){
            maxDivisor = y;
        } else {
            maxDivisor = x;
        }



        for (int i = 1; i <= maxDivisor; i++) {
            if ((x % i) == 0 && (y % i) == 0) {
                divisors.add(i);
            }
        }

        System.out.println(divisors.get(divisors.size() - z));

    }
} public class Main {
    public static void main(String[] args) {
        int x,y,z;
        Scanner sc = new Scanner(System.in);
        List<Integer> divisors = new ArrayList<Integer>();


        String temp = sc.nextLine();
        String[] tempArr = temp.split(" ");

        if (tempArr.length > 2) {
            x = Integer.parseInt(tempArr[0]);
            y = Integer.parseInt(tempArr[1]);
            z = Integer.parseInt(tempArr[2]);
        } else {
            x = 1;
            y = 1;
            z = 1;
        }

        int maxDivisor = 1;
        if (x > y) {
            maxDivisor = x;
        } else if (x < y){
            maxDivisor = y;
        } else {
            maxDivisor = x;
        }



        for (int i = 1; i <= maxDivisor; i++) {
            if ((x % i) == 0 && (y % i) == 0) {
                divisors.add(i);
            }
        }

        System.out.println(divisors.get(divisors.size() - z));

    }
} Main
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int x,y,z;
        Scanner sc = new Scanner(System.in);
        List<Integer> divisors = new ArrayList<Integer>();


        String temp = sc.nextLine();
        String[] tempArr = temp.split(" ");

        if (tempArr.length > 2) {
            x = Integer.parseInt(tempArr[0]);
            y = Integer.parseInt(tempArr[1]);
            z = Integer.parseInt(tempArr[2]);
        } else {
            x = 1;
            y = 1;
            z = 1;
        }

        int maxDivisor = 1;
        if (x > y) {
            maxDivisor = x;
        } else if (x < y){
            maxDivisor = y;
        } else {
            maxDivisor = x;
        }



        for (int i = 1; i <= maxDivisor; i++) {
            if ((x % i) == 0 && (y % i) == 0) {
                divisors.add(i);
            }
        }

        System.out.println(divisors.get(divisors.size() - z));

    }
}
