import 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());
        sc.close();
        int mas[] = new int[100];
        int sum = 1;
        for (int i = 100; i > 0; i--) {
            if (A % i == 0 && B % i == 0) {
                mas[sum] = i;
                ++sum;
            }
        }
        System.out.println(mas[K]);

    }
} import java.util.*; util.* java 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());
        sc.close();
        int mas[] = new int[100];
        int sum = 1;
        for (int i = 100; i > 0; i--) {
            if (A % i == 0 && B % i == 0) {
                mas[sum] = i;
                ++sum;
            }
        }
        System.out.println(mas[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());
        sc.close();
        int mas[] = new int[100];
        int sum = 1;
        for (int i = 100; i > 0; i--) {
            if (A % i == 0 && B % i == 0) {
                mas[sum] = i;
                ++sum;
            }
        }
        System.out.println(mas[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());
        sc.close();
        int mas[] = new int[100];
        int sum = 1;
        for (int i = 100; i > 0; i--) {
            if (A % i == 0 && B % i == 0) {
                mas[sum] = i;
                ++sum;
            }
        }
        System.out.println(mas[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 sc.close() sc.close sc int mas[] = new int[100]; mas new int[100] 100 int sum = 1; sum 1 for (int i = 100; i > 0; i--) {
            if (A % i == 0 && B % i == 0) {
                mas[sum] = i;
                ++sum;
            }
        } int i = 100; int i = 100; i 100 i > 0 i 0 i-- i-- i {
            if (A % i == 0 && B % i == 0) {
                mas[sum] = i;
                ++sum;
            }
        } {
            if (A % i == 0 && B % i == 0) {
                mas[sum] = i;
                ++sum;
            }
        } if (A % i == 0 && B % i == 0) {
                mas[sum] = i;
                ++sum;
            } A % i == 0 && B % i == 0 A % i == 0 A % i A i 0 B % i == 0 B % i B i 0 {
                mas[sum] = i;
                ++sum;
            } mas[sum] = i mas[sum] mas sum i ++sum sum System.out.println(mas[K]) System.out.println System.out System System.out mas[K] mas 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());
        sc.close();
        int mas[] = new int[100];
        int sum = 1;
        for (int i = 100; i > 0; i--) {
            if (A % i == 0 && B % i == 0) {
                mas[sum] = i;
                ++sum;
            }
        }
        System.out.println(mas[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());
        sc.close();
        int mas[] = new int[100];
        int sum = 1;
        for (int i = 100; i > 0; i--) {
            if (A % i == 0 && B % i == 0) {
                mas[sum] = i;
                ++sum;
            }
        }
        System.out.println(mas[K]);

    }
} Main
import 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());
        sc.close();
        int mas[] = new int[100];
        int sum = 1;
        for (int i = 100; i > 0; i--) {
            if (A % i == 0 && B % i == 0) {
                mas[sum] = i;
                ++sum;
            }
        }
        System.out.println(mas[K]);

    }
}