import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner scan = new Scanner(System.in);

    int a = scan.nextInt();
    int b = scan.nextInt();
    int k = scan.nextInt();

    for (int i = Math.min(a, b);; i--) {
      if ((a % i == 0) && (b % i == 0)) {
        k--;
        if (k == 0) {
          System.out.println(i);
          return;
        }
      }
    }

  }

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

  public static void main(String[] args) {

    Scanner scan = new Scanner(System.in);

    int a = scan.nextInt();
    int b = scan.nextInt();
    int k = scan.nextInt();

    for (int i = Math.min(a, b);; i--) {
      if ((a % i == 0) && (b % i == 0)) {
        k--;
        if (k == 0) {
          System.out.println(i);
          return;
        }
      }
    }

  }

} Main public static void main(String[] args) {

    Scanner scan = new Scanner(System.in);

    int a = scan.nextInt();
    int b = scan.nextInt();
    int k = scan.nextInt();

    for (int i = Math.min(a, b);; i--) {
      if ((a % i == 0) && (b % i == 0)) {
        k--;
        if (k == 0) {
          System.out.println(i);
          return;
        }
      }
    }

  } main {

    Scanner scan = new Scanner(System.in);

    int a = scan.nextInt();
    int b = scan.nextInt();
    int k = scan.nextInt();

    for (int i = Math.min(a, b);; i--) {
      if ((a % i == 0) && (b % i == 0)) {
        k--;
        if (k == 0) {
          System.out.println(i);
          return;
        }
      }
    }

  } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int a = scan.nextInt(); a scan.nextInt() scan.nextInt scan int b = scan.nextInt(); b scan.nextInt() scan.nextInt scan int k = scan.nextInt(); k scan.nextInt() scan.nextInt scan for (int i = Math.min(a, b);; i--) {
      if ((a % i == 0) && (b % i == 0)) {
        k--;
        if (k == 0) {
          System.out.println(i);
          return;
        }
      }
    } int i = Math.min(a, b); int i = Math.min(a, b); i Math.min(a, b) Math.min Math a b i-- i-- i {
      if ((a % i == 0) && (b % i == 0)) {
        k--;
        if (k == 0) {
          System.out.println(i);
          return;
        }
      }
    } {
      if ((a % i == 0) && (b % i == 0)) {
        k--;
        if (k == 0) {
          System.out.println(i);
          return;
        }
      }
    } if ((a % i == 0) && (b % i == 0)) {
        k--;
        if (k == 0) {
          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 {
        k--;
        if (k == 0) {
          System.out.println(i);
          return;
        }
      } k-- k if (k == 0) {
          System.out.println(i);
          return;
        } k == 0 k 0 {
          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 scan = new Scanner(System.in);

    int a = scan.nextInt();
    int b = scan.nextInt();
    int k = scan.nextInt();

    for (int i = Math.min(a, b);; i--) {
      if ((a % i == 0) && (b % i == 0)) {
        k--;
        if (k == 0) {
          System.out.println(i);
          return;
        }
      }
    }

  }

} public class Main {

  public static void main(String[] args) {

    Scanner scan = new Scanner(System.in);

    int a = scan.nextInt();
    int b = scan.nextInt();
    int k = scan.nextInt();

    for (int i = Math.min(a, b);; i--) {
      if ((a % i == 0) && (b % i == 0)) {
        k--;
        if (k == 0) {
          System.out.println(i);
          return;
        }
      }
    }

  }

} Main
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner scan = new Scanner(System.in);

    int a = scan.nextInt();
    int b = scan.nextInt();
    int k = scan.nextInt();

    for (int i = Math.min(a, b);; i--) {
      if ((a % i == 0) && (b % i == 0)) {
        k--;
        if (k == 0) {
          System.out.println(i);
          return;
        }
      }
    }

  }

}