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