import java.util.ArrayList;
import java.util.Scanner;

public class Main {

    private static int gcd(int a, int b) {
        return (b != 0) ? gcd(b, a % b) : a;
    }

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);

        int n = s.nextInt();
        int m = s.nextInt();
        int k = s.nextInt();

        ArrayList<Integer> divisors = new ArrayList<>();
        int g = gcd(n, m);
        for (int i = g + 1; i >= 1; i--) {
            if ((g % i) == 0) {
                k--;
                if (k == 0) {
                    System.out.println(i);
                    System.exit(0);
                }
            }
        }
    }
} import java.util.ArrayList; ArrayList java.util import java.util.Scanner; Scanner java.util public class Main {

    private static int gcd(int a, int b) {
        return (b != 0) ? gcd(b, a % b) : a;
    }

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);

        int n = s.nextInt();
        int m = s.nextInt();
        int k = s.nextInt();

        ArrayList<Integer> divisors = new ArrayList<>();
        int g = gcd(n, m);
        for (int i = g + 1; i >= 1; i--) {
            if ((g % i) == 0) {
                k--;
                if (k == 0) {
                    System.out.println(i);
                    System.exit(0);
                }
            }
        }
    }
} Main private static int gcd(int a, int b) {
        return (b != 0) ? gcd(b, a % b) : a;
    } gcd {
        return (b != 0) ? gcd(b, a % b) : a;
    } return (b != 0) ? gcd(b, a % b) : a; (b != 0) ? gcd(b, a % b) : a (b != 0) b 0 gcd(b, a % b) gcd b a % b a b a int a a int b b public static void main(String[] args) {
        Scanner s = new Scanner(System.in);

        int n = s.nextInt();
        int m = s.nextInt();
        int k = s.nextInt();

        ArrayList<Integer> divisors = new ArrayList<>();
        int g = gcd(n, m);
        for (int i = g + 1; i >= 1; i--) {
            if ((g % i) == 0) {
                k--;
                if (k == 0) {
                    System.out.println(i);
                    System.exit(0);
                }
            }
        }
    } main {
        Scanner s = new Scanner(System.in);

        int n = s.nextInt();
        int m = s.nextInt();
        int k = s.nextInt();

        ArrayList<Integer> divisors = new ArrayList<>();
        int g = gcd(n, m);
        for (int i = g + 1; i >= 1; i--) {
            if ((g % i) == 0) {
                k--;
                if (k == 0) {
                    System.out.println(i);
                    System.exit(0);
                }
            }
        }
    } Scanner s = new Scanner(System.in); s new Scanner(System.in) int n = s.nextInt(); n s.nextInt() s.nextInt s int m = s.nextInt(); m s.nextInt() s.nextInt s int k = s.nextInt(); k s.nextInt() s.nextInt s ArrayList<Integer> divisors = new ArrayList<>(); divisors new ArrayList<>() int g = gcd(n, m); g gcd(n, m) gcd n m for (int i = g + 1; i >= 1; i--) {
            if ((g % i) == 0) {
                k--;
                if (k == 0) {
                    System.out.println(i);
                    System.exit(0);
                }
            }
        } int i = g + 1; int i = g + 1; i g + 1 g 1 i >= 1 i 1 i-- i-- i {
            if ((g % i) == 0) {
                k--;
                if (k == 0) {
                    System.out.println(i);
                    System.exit(0);
                }
            }
        } {
            if ((g % i) == 0) {
                k--;
                if (k == 0) {
                    System.out.println(i);
                    System.exit(0);
                }
            }
        } if ((g % i) == 0) {
                k--;
                if (k == 0) {
                    System.out.println(i);
                    System.exit(0);
                }
            } (g % i) == 0 (g % i) g i 0 {
                k--;
                if (k == 0) {
                    System.out.println(i);
                    System.exit(0);
                }
            } k-- k if (k == 0) {
                    System.out.println(i);
                    System.exit(0);
                } k == 0 k 0 {
                    System.out.println(i);
                    System.exit(0);
                } System.out.println(i) System.out.println System.out System System.out i System.exit(0) System.exit System 0 String[] args args public class Main {

    private static int gcd(int a, int b) {
        return (b != 0) ? gcd(b, a % b) : a;
    }

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);

        int n = s.nextInt();
        int m = s.nextInt();
        int k = s.nextInt();

        ArrayList<Integer> divisors = new ArrayList<>();
        int g = gcd(n, m);
        for (int i = g + 1; i >= 1; i--) {
            if ((g % i) == 0) {
                k--;
                if (k == 0) {
                    System.out.println(i);
                    System.exit(0);
                }
            }
        }
    }
} public class Main {

    private static int gcd(int a, int b) {
        return (b != 0) ? gcd(b, a % b) : a;
    }

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);

        int n = s.nextInt();
        int m = s.nextInt();
        int k = s.nextInt();

        ArrayList<Integer> divisors = new ArrayList<>();
        int g = gcd(n, m);
        for (int i = g + 1; i >= 1; i--) {
            if ((g % i) == 0) {
                k--;
                if (k == 0) {
                    System.out.println(i);
                    System.exit(0);
                }
            }
        }
    }
} Main
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

    private static int gcd(int a, int b) {
        return (b != 0) ? gcd(b, a % b) : a;
    }

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);

        int n = s.nextInt();
        int m = s.nextInt();
        int k = s.nextInt();

        ArrayList<Integer> divisors = new ArrayList<>();
        int g = gcd(n, m);
        for (int i = g + 1; i >= 1; i--) {
            if ((g % i) == 0) {
                k--;
                if (k == 0) {
                    System.out.println(i);
                    System.exit(0);
                }
            }
        }
    }
}
