
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = Integer.parseInt(scan.next());
        int b = Integer.parseInt(scan.next());
        int k = Integer.parseInt(scan.next());
        scan.close();

        int ans = 0;
        int count = 0;

        for (int i = 100; i >= 1; i--) {
            if (a % i == 0 && b % i == 0) {
                count++;
            }
            if (count == k) {
                ans = i;
                break;
            }
        }

        System.out.println(ans);
    }

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

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = Integer.parseInt(scan.next());
        int b = Integer.parseInt(scan.next());
        int k = Integer.parseInt(scan.next());
        scan.close();

        int ans = 0;
        int count = 0;

        for (int i = 100; i >= 1; i--) {
            if (a % i == 0 && b % i == 0) {
                count++;
            }
            if (count == k) {
                ans = i;
                break;
            }
        }

        System.out.println(ans);
    }

} Main public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = Integer.parseInt(scan.next());
        int b = Integer.parseInt(scan.next());
        int k = Integer.parseInt(scan.next());
        scan.close();

        int ans = 0;
        int count = 0;

        for (int i = 100; i >= 1; i--) {
            if (a % i == 0 && b % i == 0) {
                count++;
            }
            if (count == k) {
                ans = i;
                break;
            }
        }

        System.out.println(ans);
    } main {
        Scanner scan = new Scanner(System.in);
        int a = Integer.parseInt(scan.next());
        int b = Integer.parseInt(scan.next());
        int k = Integer.parseInt(scan.next());
        scan.close();

        int ans = 0;
        int count = 0;

        for (int i = 100; i >= 1; i--) {
            if (a % i == 0 && b % i == 0) {
                count++;
            }
            if (count == k) {
                ans = i;
                break;
            }
        }

        System.out.println(ans);
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int a = Integer.parseInt(scan.next()); a Integer.parseInt(scan.next()) Integer.parseInt Integer scan.next() scan.next scan int b = Integer.parseInt(scan.next()); b Integer.parseInt(scan.next()) Integer.parseInt Integer scan.next() scan.next scan int k = Integer.parseInt(scan.next()); k Integer.parseInt(scan.next()) Integer.parseInt Integer scan.next() scan.next scan scan.close() scan.close scan int ans = 0; ans 0 int count = 0; count 0 for (int i = 100; i >= 1; i--) {
            if (a % i == 0 && b % i == 0) {
                count++;
            }
            if (count == k) {
                ans = i;
                break;
            }
        } int i = 100; int i = 100; i 100 i >= 1 i 1 i-- i-- i {
            if (a % i == 0 && b % i == 0) {
                count++;
            }
            if (count == k) {
                ans = i;
                break;
            }
        } {
            if (a % i == 0 && b % i == 0) {
                count++;
            }
            if (count == k) {
                ans = i;
                break;
            }
        } if (a % i == 0 && b % i == 0) {
                count++;
            } a % i == 0 && b % i == 0 a % i == 0 a % i a i 0 b % i == 0 b % i b i 0 {
                count++;
            } count++ count if (count == k) {
                ans = i;
                break;
            } count == k count k {
                ans = i;
                break;
            } ans = i ans i break; System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = Integer.parseInt(scan.next());
        int b = Integer.parseInt(scan.next());
        int k = Integer.parseInt(scan.next());
        scan.close();

        int ans = 0;
        int count = 0;

        for (int i = 100; i >= 1; i--) {
            if (a % i == 0 && b % i == 0) {
                count++;
            }
            if (count == k) {
                ans = i;
                break;
            }
        }

        System.out.println(ans);
    }

} public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = Integer.parseInt(scan.next());
        int b = Integer.parseInt(scan.next());
        int k = Integer.parseInt(scan.next());
        scan.close();

        int ans = 0;
        int count = 0;

        for (int i = 100; i >= 1; i--) {
            if (a % i == 0 && b % i == 0) {
                count++;
            }
            if (count == k) {
                ans = i;
                break;
            }
        }

        System.out.println(ans);
    }

} Main

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = Integer.parseInt(scan.next());
        int b = Integer.parseInt(scan.next());
        int k = Integer.parseInt(scan.next());
        scan.close();

        int ans = 0;
        int count = 0;

        for (int i = 100; i >= 1; i--) {
            if (a % i == 0 && b % i == 0) {
                count++;
            }
            if (count == k) {
                ans = i;
                break;
            }
        }

        System.out.println(ans);
    }

}
