import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.println(solve(in.nextInt(), in.nextInt(), in.nextInt()));
    }
    public static int solve(int A, int B, int K) {
        int c = 0;
        for (int i = Math.max(A, B); ; i--) {
            if (A % i == 0 && B % i == 0) {
                if (++c == K) {
                    return i;
                }
            }
        }
    }
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.println(solve(in.nextInt(), in.nextInt(), in.nextInt()));
    }
    public static int solve(int A, int B, int K) {
        int c = 0;
        for (int i = Math.max(A, B); ; i--) {
            if (A % i == 0 && B % i == 0) {
                if (++c == K) {
                    return i;
                }
            }
        }
    }
} Main public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.println(solve(in.nextInt(), in.nextInt(), in.nextInt()));
    } main {
        Scanner in = new Scanner(System.in);
        System.out.println(solve(in.nextInt(), in.nextInt(), in.nextInt()));
    } Scanner in = new Scanner(System.in); in new Scanner(System.in) System.out.println(solve(in.nextInt(), in.nextInt(), in.nextInt())) System.out.println System.out System System.out solve(in.nextInt(), in.nextInt(), in.nextInt()) solve in.nextInt() in.nextInt in in.nextInt() in.nextInt in in.nextInt() in.nextInt in String[] args args public static int solve(int A, int B, int K) {
        int c = 0;
        for (int i = Math.max(A, B); ; i--) {
            if (A % i == 0 && B % i == 0) {
                if (++c == K) {
                    return i;
                }
            }
        }
    } solve {
        int c = 0;
        for (int i = Math.max(A, B); ; i--) {
            if (A % i == 0 && B % i == 0) {
                if (++c == K) {
                    return i;
                }
            }
        }
    } int c = 0; c 0 for (int i = Math.max(A, B); ; i--) {
            if (A % i == 0 && B % i == 0) {
                if (++c == K) {
                    return i;
                }
            }
        } int i = Math.max(A, B); int i = Math.max(A, B); i Math.max(A, B) Math.max Math A B i-- i-- i {
            if (A % i == 0 && B % i == 0) {
                if (++c == K) {
                    return i;
                }
            }
        } {
            if (A % i == 0 && B % i == 0) {
                if (++c == K) {
                    return i;
                }
            }
        } if (A % i == 0 && B % i == 0) {
                if (++c == K) {
                    return i;
                }
            } A % i == 0 && B % i == 0 A % i == 0 A % i A i 0 B % i == 0 B % i B i 0 {
                if (++c == K) {
                    return i;
                }
            } if (++c == K) {
                    return i;
                } ++c == K ++c c K {
                    return i;
                } return i; i int A A int B B int K K public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.println(solve(in.nextInt(), in.nextInt(), in.nextInt()));
    }
    public static int solve(int A, int B, int K) {
        int c = 0;
        for (int i = Math.max(A, B); ; i--) {
            if (A % i == 0 && B % i == 0) {
                if (++c == K) {
                    return i;
                }
            }
        }
    }
} public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.println(solve(in.nextInt(), in.nextInt(), in.nextInt()));
    }
    public static int solve(int A, int B, int K) {
        int c = 0;
        for (int i = Math.max(A, B); ; i--) {
            if (A % i == 0 && B % i == 0) {
                if (++c == K) {
                    return i;
                }
            }
        }
    }
} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        System.out.println(solve(in.nextInt(), in.nextInt(), in.nextInt()));
    }
    public static int solve(int A, int B, int K) {
        int c = 0;
        for (int i = Math.max(A, B); ; i--) {
            if (A % i == 0 && B % i == 0) {
                if (++c == K) {
                    return i;
                }
            }
        }
    }
}
