import java.util.ArrayList;
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 big = 0;
        if(a<b){
            big = a;
        }else{
            big = b;
        }
        List<Integer> list = new ArrayList<>();
        for(int i=big;i>=1;i--) {
            if (a % i == 0 && b % i == 0) {
                list.add(i);

            }
        }
        if(list.size() != 0){
            System.out.println(list.get(k-1));
        }else{
            System.out.println(0);
        }
    }
} 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) {
        Scanner sc = new Scanner(System.in);
        int a  = sc.nextInt();
        int b  = sc.nextInt();
        int k  = sc.nextInt();
        int big = 0;
        if(a<b){
            big = a;
        }else{
            big = b;
        }
        List<Integer> list = new ArrayList<>();
        for(int i=big;i>=1;i--) {
            if (a % i == 0 && b % i == 0) {
                list.add(i);

            }
        }
        if(list.size() != 0){
            System.out.println(list.get(k-1));
        }else{
            System.out.println(0);
        }
    }
} 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 big = 0;
        if(a<b){
            big = a;
        }else{
            big = b;
        }
        List<Integer> list = new ArrayList<>();
        for(int i=big;i>=1;i--) {
            if (a % i == 0 && b % i == 0) {
                list.add(i);

            }
        }
        if(list.size() != 0){
            System.out.println(list.get(k-1));
        }else{
            System.out.println(0);
        }
    } main {
        Scanner sc = new Scanner(System.in);
        int a  = sc.nextInt();
        int b  = sc.nextInt();
        int k  = sc.nextInt();
        int big = 0;
        if(a<b){
            big = a;
        }else{
            big = b;
        }
        List<Integer> list = new ArrayList<>();
        for(int i=big;i>=1;i--) {
            if (a % i == 0 && b % i == 0) {
                list.add(i);

            }
        }
        if(list.size() != 0){
            System.out.println(list.get(k-1));
        }else{
            System.out.println(0);
        }
    } 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 big = 0; big 0 if(a<b){
            big = a;
        }else{
            big = b;
        } a<b a b {
            big = a;
        } big = a big a {
            big = b;
        } big = b big b List<Integer> list = new ArrayList<>(); list new ArrayList<>() for(int i=big;i>=1;i--) {
            if (a % i == 0 && b % i == 0) {
                list.add(i);

            }
        } int i=big; int i=big; i big i>=1 i 1 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 if(list.size() != 0){
            System.out.println(list.get(k-1));
        }else{
            System.out.println(0);
        } list.size() != 0 list.size() list.size list 0 {
            System.out.println(list.get(k-1));
        } System.out.println(list.get(k-1)) System.out.println System.out System System.out list.get(k-1) list.get list k-1 k 1 {
            System.out.println(0);
        } System.out.println(0) System.out.println System.out System System.out 0 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 big = 0;
        if(a<b){
            big = a;
        }else{
            big = b;
        }
        List<Integer> list = new ArrayList<>();
        for(int i=big;i>=1;i--) {
            if (a % i == 0 && b % i == 0) {
                list.add(i);

            }
        }
        if(list.size() != 0){
            System.out.println(list.get(k-1));
        }else{
            System.out.println(0);
        }
    }
} 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 big = 0;
        if(a<b){
            big = a;
        }else{
            big = b;
        }
        List<Integer> list = new ArrayList<>();
        for(int i=big;i>=1;i--) {
            if (a % i == 0 && b % i == 0) {
                list.add(i);

            }
        }
        if(list.size() != 0){
            System.out.println(list.get(k-1));
        }else{
            System.out.println(0);
        }
    }
} Main
import java.util.ArrayList;
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 big = 0;
        if(a<b){
            big = a;
        }else{
            big = b;
        }
        List<Integer> list = new ArrayList<>();
        for(int i=big;i>=1;i--) {
            if (a % i == 0 && b % i == 0) {
                list.add(i);

            }
        }
        if(list.size() != 0){
            System.out.println(list.get(k-1));
        }else{
            System.out.println(0);
        }
    }
}