import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

    static int gcd(int a, int b) {
        if (a < b) {
            int t = a;
            a = b;
            b = t;
        }
        if (a % b == 0) {
            return b;
        }

        return gcd(a, a % b);
    }

    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int A = std.nextInt();
        int B = std.nextInt();
        int K = std.nextInt();

        int a = gcd(A, B);
        PriorityQueue<Integer> pq = new PriorityQueue<>(Comparator.reverseOrder());

        for (int i = 1; i <= a; i++) {
            if (a % i == 0) {
                pq.add(i);
            }
        }

        int value = 0;
        for (int i = 0; i < K; i++) {
            value = pq.poll();
        }

        System.out.println(value);
    }
} import java.util.Comparator; Comparator java.util import java.util.PriorityQueue; PriorityQueue java.util import java.util.Scanner; Scanner java.util public class Main {

    static int gcd(int a, int b) {
        if (a < b) {
            int t = a;
            a = b;
            b = t;
        }
        if (a % b == 0) {
            return b;
        }

        return gcd(a, a % b);
    }

    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int A = std.nextInt();
        int B = std.nextInt();
        int K = std.nextInt();

        int a = gcd(A, B);
        PriorityQueue<Integer> pq = new PriorityQueue<>(Comparator.reverseOrder());

        for (int i = 1; i <= a; i++) {
            if (a % i == 0) {
                pq.add(i);
            }
        }

        int value = 0;
        for (int i = 0; i < K; i++) {
            value = pq.poll();
        }

        System.out.println(value);
    }
} Main static int gcd(int a, int b) {
        if (a < b) {
            int t = a;
            a = b;
            b = t;
        }
        if (a % b == 0) {
            return b;
        }

        return gcd(a, a % b);
    } gcd {
        if (a < b) {
            int t = a;
            a = b;
            b = t;
        }
        if (a % b == 0) {
            return b;
        }

        return gcd(a, a % b);
    } if (a < b) {
            int t = a;
            a = b;
            b = t;
        } a < b a b {
            int t = a;
            a = b;
            b = t;
        } int t = a; t a a = b a b b = t b t if (a % b == 0) {
            return b;
        } a % b == 0 a % b a b 0 {
            return b;
        } return b; b return gcd(a, a % b); gcd(a, a % b) gcd a a % b a b int a a int b b public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int A = std.nextInt();
        int B = std.nextInt();
        int K = std.nextInt();

        int a = gcd(A, B);
        PriorityQueue<Integer> pq = new PriorityQueue<>(Comparator.reverseOrder());

        for (int i = 1; i <= a; i++) {
            if (a % i == 0) {
                pq.add(i);
            }
        }

        int value = 0;
        for (int i = 0; i < K; i++) {
            value = pq.poll();
        }

        System.out.println(value);
    } main {
        Scanner std = new Scanner(System.in);
        int A = std.nextInt();
        int B = std.nextInt();
        int K = std.nextInt();

        int a = gcd(A, B);
        PriorityQueue<Integer> pq = new PriorityQueue<>(Comparator.reverseOrder());

        for (int i = 1; i <= a; i++) {
            if (a % i == 0) {
                pq.add(i);
            }
        }

        int value = 0;
        for (int i = 0; i < K; i++) {
            value = pq.poll();
        }

        System.out.println(value);
    } Scanner std = new Scanner(System.in); std new Scanner(System.in) int A = std.nextInt(); A std.nextInt() std.nextInt std int B = std.nextInt(); B std.nextInt() std.nextInt std int K = std.nextInt(); K std.nextInt() std.nextInt std int a = gcd(A, B); a gcd(A, B) gcd A B PriorityQueue<Integer> pq = new PriorityQueue<>(Comparator.reverseOrder()); pq new PriorityQueue<>(Comparator.reverseOrder()) for (int i = 1; i <= a; i++) {
            if (a % i == 0) {
                pq.add(i);
            }
        } int i = 1; int i = 1; i 1 i <= a i a i++ i++ i {
            if (a % i == 0) {
                pq.add(i);
            }
        } {
            if (a % i == 0) {
                pq.add(i);
            }
        } if (a % i == 0) {
                pq.add(i);
            } a % i == 0 a % i a i 0 {
                pq.add(i);
            } pq.add(i) pq.add pq i int value = 0; value 0 for (int i = 0; i < K; i++) {
            value = pq.poll();
        } int i = 0; int i = 0; i 0 i < K i K i++ i++ i {
            value = pq.poll();
        } {
            value = pq.poll();
        } value = pq.poll() value pq.poll() pq.poll pq System.out.println(value) System.out.println System.out System System.out value String[] args args public class Main {

    static int gcd(int a, int b) {
        if (a < b) {
            int t = a;
            a = b;
            b = t;
        }
        if (a % b == 0) {
            return b;
        }

        return gcd(a, a % b);
    }

    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int A = std.nextInt();
        int B = std.nextInt();
        int K = std.nextInt();

        int a = gcd(A, B);
        PriorityQueue<Integer> pq = new PriorityQueue<>(Comparator.reverseOrder());

        for (int i = 1; i <= a; i++) {
            if (a % i == 0) {
                pq.add(i);
            }
        }

        int value = 0;
        for (int i = 0; i < K; i++) {
            value = pq.poll();
        }

        System.out.println(value);
    }
} public class Main {

    static int gcd(int a, int b) {
        if (a < b) {
            int t = a;
            a = b;
            b = t;
        }
        if (a % b == 0) {
            return b;
        }

        return gcd(a, a % b);
    }

    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int A = std.nextInt();
        int B = std.nextInt();
        int K = std.nextInt();

        int a = gcd(A, B);
        PriorityQueue<Integer> pq = new PriorityQueue<>(Comparator.reverseOrder());

        for (int i = 1; i <= a; i++) {
            if (a % i == 0) {
                pq.add(i);
            }
        }

        int value = 0;
        for (int i = 0; i < K; i++) {
            value = pq.poll();
        }

        System.out.println(value);
    }
} Main
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

    static int gcd(int a, int b) {
        if (a < b) {
            int t = a;
            a = b;
            b = t;
        }
        if (a % b == 0) {
            return b;
        }

        return gcd(a, a % b);
    }

    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int A = std.nextInt();
        int B = std.nextInt();
        int K = std.nextInt();

        int a = gcd(A, B);
        PriorityQueue<Integer> pq = new PriorityQueue<>(Comparator.reverseOrder());

        for (int i = 1; i <= a; i++) {
            if (a % i == 0) {
                pq.add(i);
            }
        }

        int value = 0;
        for (int i = 0; i < K; i++) {
            value = pq.poll();
        }

        System.out.println(value);
    }
}
