import java.util.*;

public class Main {
  static int[] list;
    public static void main(String[] args) throws Exception{
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int k = sc.nextInt();
      int cnt = 0;
      for (int i = 100; 1 <= i; i--) {
        if (a%i==0 && b%i==0) {
          cnt++;
          if (cnt == k) {
            System.out.println(i);
            break;
          }
        }
      }
    }
} import java.util.*; util.* java public class Main {
  static int[] list;
    public static void main(String[] args) throws Exception{
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int k = sc.nextInt();
      int cnt = 0;
      for (int i = 100; 1 <= i; i--) {
        if (a%i==0 && b%i==0) {
          cnt++;
          if (cnt == k) {
            System.out.println(i);
            break;
          }
        }
      }
    }
} Main static int[] list; list public static void main(String[] args) throws Exception{
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int k = sc.nextInt();
      int cnt = 0;
      for (int i = 100; 1 <= i; i--) {
        if (a%i==0 && b%i==0) {
          cnt++;
          if (cnt == k) {
            System.out.println(i);
            break;
          }
        }
      }
    } main {
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int k = sc.nextInt();
      int cnt = 0;
      for (int i = 100; 1 <= i; i--) {
        if (a%i==0 && b%i==0) {
          cnt++;
          if (cnt == k) {
            System.out.println(i);
            break;
          }
        }
      }
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc int b = sc.nextInt(); b sc.nextInt() sc.nextInt sc int k = sc.nextInt(); k sc.nextInt() sc.nextInt sc int cnt = 0; cnt 0 for (int i = 100; 1 <= i; i--) {
        if (a%i==0 && b%i==0) {
          cnt++;
          if (cnt == k) {
            System.out.println(i);
            break;
          }
        }
      } int i = 100; int i = 100; i 100 1 <= i 1 i i-- i-- i {
        if (a%i==0 && b%i==0) {
          cnt++;
          if (cnt == k) {
            System.out.println(i);
            break;
          }
        }
      } {
        if (a%i==0 && b%i==0) {
          cnt++;
          if (cnt == k) {
            System.out.println(i);
            break;
          }
        }
      } if (a%i==0 && b%i==0) {
          cnt++;
          if (cnt == 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 {
          cnt++;
          if (cnt == k) {
            System.out.println(i);
            break;
          }
        } cnt++ cnt if (cnt == k) {
            System.out.println(i);
            break;
          } cnt == k cnt 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 {
  static int[] list;
    public static void main(String[] args) throws Exception{
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int k = sc.nextInt();
      int cnt = 0;
      for (int i = 100; 1 <= i; i--) {
        if (a%i==0 && b%i==0) {
          cnt++;
          if (cnt == k) {
            System.out.println(i);
            break;
          }
        }
      }
    }
} public class Main {
  static int[] list;
    public static void main(String[] args) throws Exception{
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int k = sc.nextInt();
      int cnt = 0;
      for (int i = 100; 1 <= i; i--) {
        if (a%i==0 && b%i==0) {
          cnt++;
          if (cnt == k) {
            System.out.println(i);
            break;
          }
        }
      }
    }
} Main
import java.util.*;

public class Main {
  static int[] list;
    public static void main(String[] args) throws Exception{
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int k = sc.nextInt();
      int cnt = 0;
      for (int i = 100; 1 <= i; i--) {
        if (a%i==0 && b%i==0) {
          cnt++;
          if (cnt == k) {
            System.out.println(i);
            break;
          }
        }
      }
    }
}