import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int k = sc.nextInt();
      int gcd = gcd(a, b);

      for(int i = gcd; i >= 1; i--) {
        if(a % i == 0 && b % i == 0) {
          k--;
          if(k == 0) {
            System.out.println(i);
            return;
          }
        }
      }
  }

  private static int gcd(int a, int b) {
    if(b == 0)
      return a;
    return gcd(b, a % b);
  }
} import java.util.*; util.* java public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int k = sc.nextInt();
      int gcd = gcd(a, b);

      for(int i = gcd; i >= 1; i--) {
        if(a % i == 0 && b % i == 0) {
          k--;
          if(k == 0) {
            System.out.println(i);
            return;
          }
        }
      }
  }

  private static int gcd(int a, int b) {
    if(b == 0)
      return a;
    return gcd(b, a % b);
  }
} Main public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int k = sc.nextInt();
      int gcd = gcd(a, b);

      for(int i = gcd; i >= 1; i--) {
        if(a % i == 0 && b % i == 0) {
          k--;
          if(k == 0) {
            System.out.println(i);
            return;
          }
        }
      }
  } main { 
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int k = sc.nextInt();
      int gcd = gcd(a, b);

      for(int i = gcd; i >= 1; i--) {
        if(a % i == 0 && b % i == 0) {
          k--;
          if(k == 0) {
            System.out.println(i);
            return;
          }
        }
      }
  } 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 gcd = gcd(a, b); gcd gcd(a, b) gcd a b for(int i = gcd; i >= 1; i--) {
        if(a % i == 0 && b % i == 0) {
          k--;
          if(k == 0) {
            System.out.println(i);
            return;
          }
        }
      } int i = gcd; int i = gcd; i gcd i >= 1 i 1 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 private static int gcd(int a, int b) {
    if(b == 0)
      return a;
    return gcd(b, a % b);
  } gcd {
    if(b == 0)
      return a;
    return gcd(b, a % b);
  } if(b == 0)
      return a; b == 0 b 0 return a; a return gcd(b, a % b); gcd(b, a % b) gcd b a % b a b int a a int b b public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int k = sc.nextInt();
      int gcd = gcd(a, b);

      for(int i = gcd; i >= 1; i--) {
        if(a % i == 0 && b % i == 0) {
          k--;
          if(k == 0) {
            System.out.println(i);
            return;
          }
        }
      }
  }

  private static int gcd(int a, int b) {
    if(b == 0)
      return a;
    return gcd(b, a % b);
  }
} public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int k = sc.nextInt();
      int gcd = gcd(a, b);

      for(int i = gcd; i >= 1; i--) {
        if(a % i == 0 && b % i == 0) {
          k--;
          if(k == 0) {
            System.out.println(i);
            return;
          }
        }
      }
  }

  private static int gcd(int a, int b) {
    if(b == 0)
      return a;
    return gcd(b, a % b);
  }
} Main
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int k = sc.nextInt();
      int gcd = gcd(a, b);

      for(int i = gcd; i >= 1; i--) {
        if(a % i == 0 && b % i == 0) {
          k--;
          if(k == 0) {
            System.out.println(i);
            return;
          }
        }
      }
  }

  private static int gcd(int a, int b) {
    if(b == 0)
      return a;
    return gcd(b, a % b);
  }
}