import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int k = scanner.nextInt();
        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);
                    break;
                }
            }
        }

    }
} import java.util.*; util.* java public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int k = scanner.nextInt();
        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);
                    break;
                }
            }
        }

    }
} Main public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int k = scanner.nextInt();
        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);
                    break;
                }
            }
        }

    } main {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int k = scanner.nextInt();
        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);
                    break;
                }
            }
        }

    } Scanner scanner = new Scanner(System.in); scanner 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 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);
                    break;
                }
            }
        } 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);
                    break;
                }
            }
        } {
            if (a%i==0&&b%i==0){
                count++;
                if (count==k){
                    System.out.println(i);
                    break;
                }
            }
        } if (a%i==0&&b%i==0){
                count++;
                if (count==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 {
                count++;
                if (count==k){
                    System.out.println(i);
                    break;
                }
            } count++ count if (count==k){
                    System.out.println(i);
                    break;
                } count==k count 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) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int k = scanner.nextInt();
        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);
                    break;
                }
            }
        }

    }
} public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int k = scanner.nextInt();
        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);
                    break;
                }
            }
        }

    }
} Main
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int k = scanner.nextInt();
        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);
                    break;
                }
            }
        }

    }
}