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[] ans = new int[101];
    for(int i=1; i<=100; i++){
      if( a%i == 0) ans[i]++;
      if( b%i == 0) ans[i]++;
    }
    int kb = 0;
    for(int i=100; i>=1; i--){
      if( ans[i] == 2 ) {
        ++kb;
        if( kb == k){
          System.out.println(i);
          System.exit(0);
        }
      }
    }
  }
} 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[] ans = new int[101];
    for(int i=1; i<=100; i++){
      if( a%i == 0) ans[i]++;
      if( b%i == 0) ans[i]++;
    }
    int kb = 0;
    for(int i=100; i>=1; i--){
      if( ans[i] == 2 ) {
        ++kb;
        if( kb == k){
          System.out.println(i);
          System.exit(0);
        }
      }
    }
  }
} 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[] ans = new int[101];
    for(int i=1; i<=100; i++){
      if( a%i == 0) ans[i]++;
      if( b%i == 0) ans[i]++;
    }
    int kb = 0;
    for(int i=100; i>=1; i--){
      if( ans[i] == 2 ) {
        ++kb;
        if( kb == k){
          System.out.println(i);
          System.exit(0);
        }
      }
    }
  } main {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int k = sc.nextInt();
    int[] ans = new int[101];
    for(int i=1; i<=100; i++){
      if( a%i == 0) ans[i]++;
      if( b%i == 0) ans[i]++;
    }
    int kb = 0;
    for(int i=100; i>=1; i--){
      if( ans[i] == 2 ) {
        ++kb;
        if( kb == k){
          System.out.println(i);
          System.exit(0);
        }
      }
    }
  } 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[] ans = new int[101]; ans new int[101] 101 for(int i=1; i<=100; i++){
      if( a%i == 0) ans[i]++;
      if( b%i == 0) ans[i]++;
    } int i=1; int i=1; i 1 i<=100 i 100 i++ i++ i {
      if( a%i == 0) ans[i]++;
      if( b%i == 0) ans[i]++;
    } {
      if( a%i == 0) ans[i]++;
      if( b%i == 0) ans[i]++;
    } if( a%i == 0) ans[i]++; a%i == 0 a%i a i 0 ans[i]++ ans[i] ans i if( b%i == 0) ans[i]++; b%i == 0 b%i b i 0 ans[i]++ ans[i] ans i int kb = 0; kb 0 for(int i=100; i>=1; i--){
      if( ans[i] == 2 ) {
        ++kb;
        if( kb == k){
          System.out.println(i);
          System.exit(0);
        }
      }
    } int i=100; int i=100; i 100 i>=1 i 1 i-- i-- i {
      if( ans[i] == 2 ) {
        ++kb;
        if( kb == k){
          System.out.println(i);
          System.exit(0);
        }
      }
    } {
      if( ans[i] == 2 ) {
        ++kb;
        if( kb == k){
          System.out.println(i);
          System.exit(0);
        }
      }
    } if( ans[i] == 2 ) {
        ++kb;
        if( kb == k){
          System.out.println(i);
          System.exit(0);
        }
      } ans[i] == 2 ans[i] ans i 2 {
        ++kb;
        if( kb == k){
          System.out.println(i);
          System.exit(0);
        }
      } ++kb kb if( kb == k){
          System.out.println(i);
          System.exit(0);
        } kb == k kb k {
          System.out.println(i);
          System.exit(0);
        } System.out.println(i) System.out.println System.out System System.out i System.exit(0) System.exit System 0 String[] args args 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[] ans = new int[101];
    for(int i=1; i<=100; i++){
      if( a%i == 0) ans[i]++;
      if( b%i == 0) ans[i]++;
    }
    int kb = 0;
    for(int i=100; i>=1; i--){
      if( ans[i] == 2 ) {
        ++kb;
        if( kb == k){
          System.out.println(i);
          System.exit(0);
        }
      }
    }
  }
} 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[] ans = new int[101];
    for(int i=1; i<=100; i++){
      if( a%i == 0) ans[i]++;
      if( b%i == 0) ans[i]++;
    }
    int kb = 0;
    for(int i=100; i>=1; i--){
      if( ans[i] == 2 ) {
        ++kb;
        if( kb == k){
          System.out.println(i);
          System.exit(0);
        }
      }
    }
  }
} 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[] ans = new int[101];
    for(int i=1; i<=100; i++){
      if( a%i == 0) ans[i]++;
      if( b%i == 0) ans[i]++;
    }
    int kb = 0;
    for(int i=100; i>=1; i--){
      if( ans[i] == 2 ) {
        ++kb;
        if( kb == k){
          System.out.println(i);
          System.exit(0);
        }
      }
    }
  }
}