import java.util.Scanner;
import java.util.ArrayList;

public class Main {
  public static void main (String[] args) {
    Scanner in = new Scanner(System.in);

    while (in.hasNext()) {
      int A = in.nextInt();
      int B = in.nextInt();
      int K = in.nextInt();

      ArrayList<Integer> commonDivisor = new ArrayList<Integer>();

      for (int i = 1; i <= 100; ++i) {
        if (A % i == 0 && B % i == 0) {
          commonDivisor.add(i);
        } 
      }

      System.out.println(commonDivisor.get(commonDivisor.size() - K));
    }
  }
} import java.util.Scanner; Scanner java.util import java.util.ArrayList; ArrayList java.util public class Main {
  public static void main (String[] args) {
    Scanner in = new Scanner(System.in);

    while (in.hasNext()) {
      int A = in.nextInt();
      int B = in.nextInt();
      int K = in.nextInt();

      ArrayList<Integer> commonDivisor = new ArrayList<Integer>();

      for (int i = 1; i <= 100; ++i) {
        if (A % i == 0 && B % i == 0) {
          commonDivisor.add(i);
        } 
      }

      System.out.println(commonDivisor.get(commonDivisor.size() - K));
    }
  }
} Main public static void main (String[] args) {
    Scanner in = new Scanner(System.in);

    while (in.hasNext()) {
      int A = in.nextInt();
      int B = in.nextInt();
      int K = in.nextInt();

      ArrayList<Integer> commonDivisor = new ArrayList<Integer>();

      for (int i = 1; i <= 100; ++i) {
        if (A % i == 0 && B % i == 0) {
          commonDivisor.add(i);
        } 
      }

      System.out.println(commonDivisor.get(commonDivisor.size() - K));
    }
  } main {
    Scanner in = new Scanner(System.in);

    while (in.hasNext()) {
      int A = in.nextInt();
      int B = in.nextInt();
      int K = in.nextInt();

      ArrayList<Integer> commonDivisor = new ArrayList<Integer>();

      for (int i = 1; i <= 100; ++i) {
        if (A % i == 0 && B % i == 0) {
          commonDivisor.add(i);
        } 
      }

      System.out.println(commonDivisor.get(commonDivisor.size() - K));
    }
  } Scanner in = new Scanner(System.in); in new Scanner(System.in) while (in.hasNext()) {
      int A = in.nextInt();
      int B = in.nextInt();
      int K = in.nextInt();

      ArrayList<Integer> commonDivisor = new ArrayList<Integer>();

      for (int i = 1; i <= 100; ++i) {
        if (A % i == 0 && B % i == 0) {
          commonDivisor.add(i);
        } 
      }

      System.out.println(commonDivisor.get(commonDivisor.size() - K));
    } in.hasNext() in.hasNext in {
      int A = in.nextInt();
      int B = in.nextInt();
      int K = in.nextInt();

      ArrayList<Integer> commonDivisor = new ArrayList<Integer>();

      for (int i = 1; i <= 100; ++i) {
        if (A % i == 0 && B % i == 0) {
          commonDivisor.add(i);
        } 
      }

      System.out.println(commonDivisor.get(commonDivisor.size() - K));
    } int A = in.nextInt(); A in.nextInt() in.nextInt in int B = in.nextInt(); B in.nextInt() in.nextInt in int K = in.nextInt(); K in.nextInt() in.nextInt in ArrayList<Integer> commonDivisor = new ArrayList<Integer>(); commonDivisor new ArrayList<Integer>() for (int i = 1; i <= 100; ++i) {
        if (A % i == 0 && B % i == 0) {
          commonDivisor.add(i);
        } 
      } int i = 1; int i = 1; i 1 i <= 100 i 100 ++i ++i i {
        if (A % i == 0 && B % i == 0) {
          commonDivisor.add(i);
        } 
      } {
        if (A % i == 0 && B % i == 0) {
          commonDivisor.add(i);
        } 
      } if (A % i == 0 && B % i == 0) {
          commonDivisor.add(i);
        } A % i == 0 && B % i == 0 A % i == 0 A % i A i 0 B % i == 0 B % i B i 0 {
          commonDivisor.add(i);
        } commonDivisor.add(i) commonDivisor.add commonDivisor i System.out.println(commonDivisor.get(commonDivisor.size() - K)) System.out.println System.out System System.out commonDivisor.get(commonDivisor.size() - K) commonDivisor.get commonDivisor commonDivisor.size() - K commonDivisor.size() commonDivisor.size commonDivisor K String[] args args public class Main {
  public static void main (String[] args) {
    Scanner in = new Scanner(System.in);

    while (in.hasNext()) {
      int A = in.nextInt();
      int B = in.nextInt();
      int K = in.nextInt();

      ArrayList<Integer> commonDivisor = new ArrayList<Integer>();

      for (int i = 1; i <= 100; ++i) {
        if (A % i == 0 && B % i == 0) {
          commonDivisor.add(i);
        } 
      }

      System.out.println(commonDivisor.get(commonDivisor.size() - K));
    }
  }
} public class Main {
  public static void main (String[] args) {
    Scanner in = new Scanner(System.in);

    while (in.hasNext()) {
      int A = in.nextInt();
      int B = in.nextInt();
      int K = in.nextInt();

      ArrayList<Integer> commonDivisor = new ArrayList<Integer>();

      for (int i = 1; i <= 100; ++i) {
        if (A % i == 0 && B % i == 0) {
          commonDivisor.add(i);
        } 
      }

      System.out.println(commonDivisor.get(commonDivisor.size() - K));
    }
  }
} Main
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
  public static void main (String[] args) {
    Scanner in = new Scanner(System.in);

    while (in.hasNext()) {
      int A = in.nextInt();
      int B = in.nextInt();
      int K = in.nextInt();

      ArrayList<Integer> commonDivisor = new ArrayList<Integer>();

      for (int i = 1; i <= 100; ++i) {
        if (A % i == 0 && B % i == 0) {
          commonDivisor.add(i);
        } 
      }

      System.out.println(commonDivisor.get(commonDivisor.size() - K));
    }
  }
}