import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int a = Integer.parseInt(str[0]);
    int b = Integer.parseInt(str[1]);
    int k = Integer.parseInt(str[2]);
    
    int[] divisor_array = new int[k];
    
    for(int i = Math.min(a,b), j = 0; i>=1; i--) {
      if(a%i==0 && b%i==0){
        divisor_array[j] = i;
        j++;
      }
      if(j == k)
        break;
    }
    System.out.println(divisor_array[k-1]);
  }
} import java.io.BufferedReader; BufferedReader java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.IOException; IOException java.io public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int a = Integer.parseInt(str[0]);
    int b = Integer.parseInt(str[1]);
    int k = Integer.parseInt(str[2]);
    
    int[] divisor_array = new int[k];
    
    for(int i = Math.min(a,b), j = 0; i>=1; i--) {
      if(a%i==0 && b%i==0){
        divisor_array[j] = i;
        j++;
      }
      if(j == k)
        break;
    }
    System.out.println(divisor_array[k-1]);
  }
} Main public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int a = Integer.parseInt(str[0]);
    int b = Integer.parseInt(str[1]);
    int k = Integer.parseInt(str[2]);
    
    int[] divisor_array = new int[k];
    
    for(int i = Math.min(a,b), j = 0; i>=1; i--) {
      if(a%i==0 && b%i==0){
        divisor_array[j] = i;
        j++;
      }
      if(j == k)
        break;
    }
    System.out.println(divisor_array[k-1]);
  } main {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int a = Integer.parseInt(str[0]);
    int b = Integer.parseInt(str[1]);
    int k = Integer.parseInt(str[2]);
    
    int[] divisor_array = new int[k];
    
    for(int i = Math.min(a,b), j = 0; i>=1; i--) {
      if(a%i==0 && b%i==0){
        divisor_array[j] = i;
        j++;
      }
      if(j == k)
        break;
    }
    System.out.println(divisor_array[k-1]);
  } BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); in new BufferedReader(new InputStreamReader(System.in)) String[] str = in.readLine().split(" "); str in.readLine().split(" ") in.readLine().split in.readLine() in.readLine in " " int a = Integer.parseInt(str[0]); a Integer.parseInt(str[0]) Integer.parseInt Integer str[0] str 0 int b = Integer.parseInt(str[1]); b Integer.parseInt(str[1]) Integer.parseInt Integer str[1] str 1 int k = Integer.parseInt(str[2]); k Integer.parseInt(str[2]) Integer.parseInt Integer str[2] str 2 int[] divisor_array = new int[k]; divisor_array new int[k] k for(int i = Math.min(a,b), j = 0; i>=1; i--) {
      if(a%i==0 && b%i==0){
        divisor_array[j] = i;
        j++;
      }
      if(j == k)
        break;
    } int i = Math.min(a,b), j = 0; int i = Math.min(a,b) i Math.min(a,b) Math.min Math a b j = 0; j 0 i>=1 i 1 i-- i-- i {
      if(a%i==0 && b%i==0){
        divisor_array[j] = i;
        j++;
      }
      if(j == k)
        break;
    } {
      if(a%i==0 && b%i==0){
        divisor_array[j] = i;
        j++;
      }
      if(j == k)
        break;
    } if(a%i==0 && b%i==0){
        divisor_array[j] = i;
        j++;
      } a%i==0 && b%i==0 a%i==0 a%i a i 0 b%i==0 b%i b i 0 {
        divisor_array[j] = i;
        j++;
      } divisor_array[j] = i divisor_array[j] divisor_array j i j++ j if(j == k)
        break; j == k j k break; System.out.println(divisor_array[k-1]) System.out.println System.out System System.out divisor_array[k-1] divisor_array k-1 k 1 String[] args args public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int a = Integer.parseInt(str[0]);
    int b = Integer.parseInt(str[1]);
    int k = Integer.parseInt(str[2]);
    
    int[] divisor_array = new int[k];
    
    for(int i = Math.min(a,b), j = 0; i>=1; i--) {
      if(a%i==0 && b%i==0){
        divisor_array[j] = i;
        j++;
      }
      if(j == k)
        break;
    }
    System.out.println(divisor_array[k-1]);
  }
} public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int a = Integer.parseInt(str[0]);
    int b = Integer.parseInt(str[1]);
    int k = Integer.parseInt(str[2]);
    
    int[] divisor_array = new int[k];
    
    for(int i = Math.min(a,b), j = 0; i>=1; i--) {
      if(a%i==0 && b%i==0){
        divisor_array[j] = i;
        j++;
      }
      if(j == k)
        break;
    }
    System.out.println(divisor_array[k-1]);
  }
} Main
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int a = Integer.parseInt(str[0]);
    int b = Integer.parseInt(str[1]);
    int k = Integer.parseInt(str[2]);
    
    int[] divisor_array = new int[k];
    
    for(int i = Math.min(a,b), j = 0; i>=1; i--) {
      if(a%i==0 && b%i==0){
        divisor_array[j] = i;
        j++;
      }
      if(j == k)
        break;
    }
    System.out.println(divisor_array[k-1]);
  }
}