import java.util.Scanner;

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

public class Main {
    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            int A = scanner.nextInt();
            int B = scanner.nextInt();
            int k = scanner.nextInt();
            int cnt = 0;
            for (int i = (int)Math.max(A,B); i >0; i--) {
                if (A % i == 0 && B % i == 0) {
                    if (++cnt == k) {
                        System.out.println(i);
                        break;
                    }
                }
            }
        }
    }
}
