import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int lhs = scanner.nextInt();
    int rhs = scanner.nextInt();
    int k = scanner.nextInt();

    int sqrt = (int)Math.sqrt(rhs);
    TreeSet<Integer> set = new TreeSet<Integer>();
    for (int ix = 1; ix <= Math.min(lhs, rhs); ix++) {
      if (lhs % ix == 0 && rhs % ix == 0) {
        set.add(ix);
      }
    }

    Iterator<Integer> it = set.descendingIterator();
    while (--k > 0) {
      it.next();
    }

    System.out.println(it.next());
  }
} import java.util.*; util.* java public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int lhs = scanner.nextInt();
    int rhs = scanner.nextInt();
    int k = scanner.nextInt();

    int sqrt = (int)Math.sqrt(rhs);
    TreeSet<Integer> set = new TreeSet<Integer>();
    for (int ix = 1; ix <= Math.min(lhs, rhs); ix++) {
      if (lhs % ix == 0 && rhs % ix == 0) {
        set.add(ix);
      }
    }

    Iterator<Integer> it = set.descendingIterator();
    while (--k > 0) {
      it.next();
    }

    System.out.println(it.next());
  }
} Main public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int lhs = scanner.nextInt();
    int rhs = scanner.nextInt();
    int k = scanner.nextInt();

    int sqrt = (int)Math.sqrt(rhs);
    TreeSet<Integer> set = new TreeSet<Integer>();
    for (int ix = 1; ix <= Math.min(lhs, rhs); ix++) {
      if (lhs % ix == 0 && rhs % ix == 0) {
        set.add(ix);
      }
    }

    Iterator<Integer> it = set.descendingIterator();
    while (--k > 0) {
      it.next();
    }

    System.out.println(it.next());
  } main {
    Scanner scanner = new Scanner(System.in);
    int lhs = scanner.nextInt();
    int rhs = scanner.nextInt();
    int k = scanner.nextInt();

    int sqrt = (int)Math.sqrt(rhs);
    TreeSet<Integer> set = new TreeSet<Integer>();
    for (int ix = 1; ix <= Math.min(lhs, rhs); ix++) {
      if (lhs % ix == 0 && rhs % ix == 0) {
        set.add(ix);
      }
    }

    Iterator<Integer> it = set.descendingIterator();
    while (--k > 0) {
      it.next();
    }

    System.out.println(it.next());
  } Scanner scanner = new Scanner(System.in); scanner new Scanner(System.in) int lhs = scanner.nextInt(); lhs scanner.nextInt() scanner.nextInt scanner int rhs = scanner.nextInt(); rhs scanner.nextInt() scanner.nextInt scanner int k = scanner.nextInt(); k scanner.nextInt() scanner.nextInt scanner int sqrt = (int)Math.sqrt(rhs); sqrt (int)Math.sqrt(rhs) Math.sqrt Math rhs TreeSet<Integer> set = new TreeSet<Integer>(); set new TreeSet<Integer>() for (int ix = 1; ix <= Math.min(lhs, rhs); ix++) {
      if (lhs % ix == 0 && rhs % ix == 0) {
        set.add(ix);
      }
    } int ix = 1; int ix = 1; ix 1 ix <= Math.min(lhs, rhs) ix Math.min(lhs, rhs) Math.min Math lhs rhs ix++ ix++ ix {
      if (lhs % ix == 0 && rhs % ix == 0) {
        set.add(ix);
      }
    } {
      if (lhs % ix == 0 && rhs % ix == 0) {
        set.add(ix);
      }
    } if (lhs % ix == 0 && rhs % ix == 0) {
        set.add(ix);
      } lhs % ix == 0 && rhs % ix == 0 lhs % ix == 0 lhs % ix lhs ix 0 rhs % ix == 0 rhs % ix rhs ix 0 {
        set.add(ix);
      } set.add(ix) set.add set ix Iterator<Integer> it = set.descendingIterator(); it set.descendingIterator() set.descendingIterator set while (--k > 0) {
      it.next();
    } --k > 0 --k k 0 {
      it.next();
    } it.next() it.next it System.out.println(it.next()) System.out.println System.out System System.out it.next() it.next it String[] args args public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int lhs = scanner.nextInt();
    int rhs = scanner.nextInt();
    int k = scanner.nextInt();

    int sqrt = (int)Math.sqrt(rhs);
    TreeSet<Integer> set = new TreeSet<Integer>();
    for (int ix = 1; ix <= Math.min(lhs, rhs); ix++) {
      if (lhs % ix == 0 && rhs % ix == 0) {
        set.add(ix);
      }
    }

    Iterator<Integer> it = set.descendingIterator();
    while (--k > 0) {
      it.next();
    }

    System.out.println(it.next());
  }
} public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int lhs = scanner.nextInt();
    int rhs = scanner.nextInt();
    int k = scanner.nextInt();

    int sqrt = (int)Math.sqrt(rhs);
    TreeSet<Integer> set = new TreeSet<Integer>();
    for (int ix = 1; ix <= Math.min(lhs, rhs); ix++) {
      if (lhs % ix == 0 && rhs % ix == 0) {
        set.add(ix);
      }
    }

    Iterator<Integer> it = set.descendingIterator();
    while (--k > 0) {
      it.next();
    }

    System.out.println(it.next());
  }
} Main
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int lhs = scanner.nextInt();
    int rhs = scanner.nextInt();
    int k = scanner.nextInt();

    int sqrt = (int)Math.sqrt(rhs);
    TreeSet<Integer> set = new TreeSet<Integer>();
    for (int ix = 1; ix <= Math.min(lhs, rhs); ix++) {
      if (lhs % ix == 0 && rhs % ix == 0) {
        set.add(ix);
      }
    }

    Iterator<Integer> it = set.descendingIterator();
    while (--k > 0) {
      it.next();
    }

    System.out.println(it.next());
  }
}