import java.util.*;
import java.io.*;

public class Main{
  public static void main(String[] args) throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] s = br.readLine().split(" ");
    int a = Integer.parseInt(s[0]);
    int b = Integer.parseInt(s[1]);
    int k = Integer.parseInt(s[2]);
    
    int ans;
    int count = 0;
    for(int i = Math.max(a, b); ; i--){
      if(a % i == 0 && b % i == 0){
        count++;
        if(count == k){
          ans = i;
          break;
        }
      }
    }
    System.out.println(ans);
  }
} import java.util.*; util.* java import java.io.*; io.* java public class Main{
  public static void main(String[] args) throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] s = br.readLine().split(" ");
    int a = Integer.parseInt(s[0]);
    int b = Integer.parseInt(s[1]);
    int k = Integer.parseInt(s[2]);
    
    int ans;
    int count = 0;
    for(int i = Math.max(a, b); ; i--){
      if(a % i == 0 && b % i == 0){
        count++;
        if(count == k){
          ans = i;
          break;
        }
      }
    }
    System.out.println(ans);
  }
} Main public static void main(String[] args) throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] s = br.readLine().split(" ");
    int a = Integer.parseInt(s[0]);
    int b = Integer.parseInt(s[1]);
    int k = Integer.parseInt(s[2]);
    
    int ans;
    int count = 0;
    for(int i = Math.max(a, b); ; i--){
      if(a % i == 0 && b % i == 0){
        count++;
        if(count == k){
          ans = i;
          break;
        }
      }
    }
    System.out.println(ans);
  } main {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] s = br.readLine().split(" ");
    int a = Integer.parseInt(s[0]);
    int b = Integer.parseInt(s[1]);
    int k = Integer.parseInt(s[2]);
    
    int ans;
    int count = 0;
    for(int i = Math.max(a, b); ; i--){
      if(a % i == 0 && b % i == 0){
        count++;
        if(count == k){
          ans = i;
          break;
        }
      }
    }
    System.out.println(ans);
  } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] s = br.readLine().split(" "); s br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int a = Integer.parseInt(s[0]); a Integer.parseInt(s[0]) Integer.parseInt Integer s[0] s 0 int b = Integer.parseInt(s[1]); b Integer.parseInt(s[1]) Integer.parseInt Integer s[1] s 1 int k = Integer.parseInt(s[2]); k Integer.parseInt(s[2]) Integer.parseInt Integer s[2] s 2 int ans; ans int count = 0; count 0 for(int i = Math.max(a, b); ; i--){
      if(a % i == 0 && b % i == 0){
        count++;
        if(count == k){
          ans = i;
          break;
        }
      }
    } int i = Math.max(a, b); int i = Math.max(a, b); i Math.max(a, b) Math.max Math a b i-- i-- i {
      if(a % i == 0 && b % i == 0){
        count++;
        if(count == k){
          ans = i;
          break;
        }
      }
    } {
      if(a % i == 0 && b % i == 0){
        count++;
        if(count == k){
          ans = i;
          break;
        }
      }
    } if(a % i == 0 && b % i == 0){
        count++;
        if(count == k){
          ans = i;
          break;
        }
      } a % i == 0 && b % i == 0 a % i == 0 a % i a i 0 b % i == 0 b % i b i 0 {
        count++;
        if(count == k){
          ans = i;
          break;
        }
      } count++ count if(count == k){
          ans = i;
          break;
        } count == k count k {
          ans = i;
          break;
        } ans = i ans i break; System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main{
  public static void main(String[] args) throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] s = br.readLine().split(" ");
    int a = Integer.parseInt(s[0]);
    int b = Integer.parseInt(s[1]);
    int k = Integer.parseInt(s[2]);
    
    int ans;
    int count = 0;
    for(int i = Math.max(a, b); ; i--){
      if(a % i == 0 && b % i == 0){
        count++;
        if(count == k){
          ans = i;
          break;
        }
      }
    }
    System.out.println(ans);
  }
} public class Main{
  public static void main(String[] args) throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] s = br.readLine().split(" ");
    int a = Integer.parseInt(s[0]);
    int b = Integer.parseInt(s[1]);
    int k = Integer.parseInt(s[2]);
    
    int ans;
    int count = 0;
    for(int i = Math.max(a, b); ; i--){
      if(a % i == 0 && b % i == 0){
        count++;
        if(count == k){
          ans = i;
          break;
        }
      }
    }
    System.out.println(ans);
  }
} Main
import java.util.*;
import java.io.*;

public class Main{
  public static void main(String[] args) throws Exception{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] s = br.readLine().split(" ");
    int a = Integer.parseInt(s[0]);
    int b = Integer.parseInt(s[1]);
    int k = Integer.parseInt(s[2]);
    
    int ans;
    int count = 0;
    for(int i = Math.max(a, b); ; i--){
      if(a % i == 0 && b % i == 0){
        count++;
        if(count == k){
          ans = i;
          break;
        }
      }
    }
    System.out.println(ans);
  }
}