import 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 number = 0;
        int result = Math.min(a, b);
        while (number < k) {
            if (a % result ==  0 && b % result == 0) {
                number++;
            }
            result--;
        }
        System.out.println(result + 1);
        sc.close();
    }
} import java.util.*; util.* java 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 number = 0;
        int result = Math.min(a, b);
        while (number < k) {
            if (a % result ==  0 && b % result == 0) {
                number++;
            }
            result--;
        }
        System.out.println(result + 1);
        sc.close();
    }
} 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 number = 0;
        int result = Math.min(a, b);
        while (number < k) {
            if (a % result ==  0 && b % result == 0) {
                number++;
            }
            result--;
        }
        System.out.println(result + 1);
        sc.close();
    } main {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        int number = 0;
        int result = Math.min(a, b);
        while (number < k) {
            if (a % result ==  0 && b % result == 0) {
                number++;
            }
            result--;
        }
        System.out.println(result + 1);
        sc.close();
    } 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 number = 0; number 0 int result = Math.min(a, b); result Math.min(a, b) Math.min Math a b while (number < k) {
            if (a % result ==  0 && b % result == 0) {
                number++;
            }
            result--;
        } number < k number k {
            if (a % result ==  0 && b % result == 0) {
                number++;
            }
            result--;
        } if (a % result ==  0 && b % result == 0) {
                number++;
            } a % result ==  0 && b % result == 0 a % result ==  0 a % result a result 0 b % result == 0 b % result b result 0 {
                number++;
            } number++ number result-- result System.out.println(result + 1) System.out.println System.out System System.out result + 1 result 1 sc.close() sc.close sc 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 number = 0;
        int result = Math.min(a, b);
        while (number < k) {
            if (a % result ==  0 && b % result == 0) {
                number++;
            }
            result--;
        }
        System.out.println(result + 1);
        sc.close();
    }
} 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 number = 0;
        int result = Math.min(a, b);
        while (number < k) {
            if (a % result ==  0 && b % result == 0) {
                number++;
            }
            result--;
        }
        System.out.println(result + 1);
        sc.close();
    }
} Main
import 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 number = 0;
        int result = Math.min(a, b);
        while (number < k) {
            if (a % result ==  0 && b % result == 0) {
                number++;
            }
            result--;
        }
        System.out.println(result + 1);
        sc.close();
    }
}