import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();
        long K = sc.nextLong();
        sc.close();

        int count = 0;
        for (int i = 100; i>0; i--) {
            if (A%i == 0 && B%i == 0) {
                count++;
                if (count == K) {
                    System.out.println(i);
                    return;
                }
            }
        }

    }


} import java.util.*; util.* java public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();
        long K = sc.nextLong();
        sc.close();

        int count = 0;
        for (int i = 100; i>0; i--) {
            if (A%i == 0 && B%i == 0) {
                count++;
                if (count == K) {
                    System.out.println(i);
                    return;
                }
            }
        }

    }


} Main public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();
        long K = sc.nextLong();
        sc.close();

        int count = 0;
        for (int i = 100; i>0; i--) {
            if (A%i == 0 && B%i == 0) {
                count++;
                if (count == K) {
                    System.out.println(i);
                    return;
                }
            }
        }

    } main {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();
        long K = sc.nextLong();
        sc.close();

        int count = 0;
        for (int i = 100; i>0; i--) {
            if (A%i == 0 && B%i == 0) {
                count++;
                if (count == K) {
                    System.out.println(i);
                    return;
                }
            }
        }

    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long A = sc.nextLong(); A sc.nextLong() sc.nextLong sc long B = sc.nextLong(); B sc.nextLong() sc.nextLong sc long K = sc.nextLong(); K sc.nextLong() sc.nextLong sc sc.close() sc.close sc int count = 0; count 0 for (int i = 100; i>0; i--) {
            if (A%i == 0 && B%i == 0) {
                count++;
                if (count == K) {
                    System.out.println(i);
                    return;
                }
            }
        } int i = 100; int i = 100; i 100 i>0 i 0 i-- i-- i {
            if (A%i == 0 && B%i == 0) {
                count++;
                if (count == K) {
                    System.out.println(i);
                    return;
                }
            }
        } {
            if (A%i == 0 && B%i == 0) {
                count++;
                if (count == K) {
                    System.out.println(i);
                    return;
                }
            }
        } if (A%i == 0 && B%i == 0) {
                count++;
                if (count == K) {
                    System.out.println(i);
                    return;
                }
            } A%i == 0 && B%i == 0 A%i == 0 A%i A i 0 B%i == 0 B%i B i 0 {
                count++;
                if (count == K) {
                    System.out.println(i);
                    return;
                }
            } count++ count if (count == K) {
                    System.out.println(i);
                    return;
                } count == K count K {
                    System.out.println(i);
                    return;
                } System.out.println(i) System.out.println System.out System System.out i return; String[] args args public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();
        long K = sc.nextLong();
        sc.close();

        int count = 0;
        for (int i = 100; i>0; i--) {
            if (A%i == 0 && B%i == 0) {
                count++;
                if (count == K) {
                    System.out.println(i);
                    return;
                }
            }
        }

    }


} public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();
        long K = sc.nextLong();
        sc.close();

        int count = 0;
        for (int i = 100; i>0; i--) {
            if (A%i == 0 && B%i == 0) {
                count++;
                if (count == K) {
                    System.out.println(i);
                    return;
                }
            }
        }

    }


} Main
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long B = sc.nextLong();
        long K = sc.nextLong();
        sc.close();

        int count = 0;
        for (int i = 100; i>0; i--) {
            if (A%i == 0 && B%i == 0) {
                count++;
                if (count == K) {
                    System.out.println(i);
                    return;
                }
            }
        }

    }


}