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 = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        int K = Integer.parseInt(sc.next());
        int len = (A < B) ? A : B;
        List r = new ArrayList<Integer>();
        for (int i = 1; i <= len; i++) {
            if (A % i == 0 && B % i == 0) r.add(i);
        }
        System.out.println(r.get(r.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 = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        int K = Integer.parseInt(sc.next());
        int len = (A < B) ? A : B;
        List r = new ArrayList<Integer>();
        for (int i = 1; i <= len; i++) {
            if (A % i == 0 && B % i == 0) r.add(i);
        }
        System.out.println(r.get(r.size()-K));
    }
} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        int K = Integer.parseInt(sc.next());
        int len = (A < B) ? A : B;
        List r = new ArrayList<Integer>();
        for (int i = 1; i <= len; i++) {
            if (A % i == 0 && B % i == 0) r.add(i);
        }
        System.out.println(r.get(r.size()-K));
    } main {
        Scanner sc = new Scanner(System.in);
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        int K = Integer.parseInt(sc.next());
        int len = (A < B) ? A : B;
        List r = new ArrayList<Integer>();
        for (int i = 1; i <= len; i++) {
            if (A % i == 0 && B % i == 0) r.add(i);
        }
        System.out.println(r.get(r.size()-K));
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int A = Integer.parseInt(sc.next()); A Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int B = Integer.parseInt(sc.next()); B Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int K = Integer.parseInt(sc.next()); K Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int len = (A < B) ? A : B; len (A < B) ? A : B (A < B) A B A B List r = new ArrayList<Integer>(); r new ArrayList<Integer>() for (int i = 1; i <= len; i++) {
            if (A % i == 0 && B % i == 0) r.add(i);
        } int i = 1; int i = 1; i 1 i <= len i len i++ i++ i {
            if (A % i == 0 && B % i == 0) r.add(i);
        } {
            if (A % i == 0 && B % i == 0) r.add(i);
        } if (A % i == 0 && B % i == 0) r.add(i); A % i == 0 && B % i == 0 A % i == 0 A % i A i 0 B % i == 0 B % i B i 0 r.add(i) r.add r i System.out.println(r.get(r.size()-K)) System.out.println System.out System System.out r.get(r.size()-K) r.get r r.size()-K r.size() r.size r K String[] args args public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        int K = Integer.parseInt(sc.next());
        int len = (A < B) ? A : B;
        List r = new ArrayList<Integer>();
        for (int i = 1; i <= len; i++) {
            if (A % i == 0 && B % i == 0) r.add(i);
        }
        System.out.println(r.get(r.size()-K));
    }
} public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        int K = Integer.parseInt(sc.next());
        int len = (A < B) ? A : B;
        List r = new ArrayList<Integer>();
        for (int i = 1; i <= len; i++) {
            if (A % i == 0 && B % i == 0) r.add(i);
        }
        System.out.println(r.get(r.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 = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        int K = Integer.parseInt(sc.next());
        int len = (A < B) ? A : B;
        List r = new ArrayList<Integer>();
        for (int i = 1; i <= len; i++) {
            if (A % i == 0 && B % i == 0) r.add(i);
        }
        System.out.println(r.get(r.size()-K));
    }
}