import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int A = Integer.parseInt(sc.next());
    int B = Integer.parseInt(sc.next());
    int K = Integer.parseInt(sc.next());
    
    int ans = 0;
    int count = 0;
    for(int i = 100; i >= 1; i--){
      if(A%i == 0 && B%i == 0){
        ans = i;
        count++;
      }
      if(count == K){
        break;
      }
    }
    
    System.out.println(ans);
  }
} import java.util.*; util.* java public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int A = Integer.parseInt(sc.next());
    int B = Integer.parseInt(sc.next());
    int K = Integer.parseInt(sc.next());
    
    int ans = 0;
    int count = 0;
    for(int i = 100; i >= 1; i--){
      if(A%i == 0 && B%i == 0){
        ans = i;
        count++;
      }
      if(count == K){
        break;
      }
    }
    
    System.out.println(ans);
  }
} Main public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int A = Integer.parseInt(sc.next());
    int B = Integer.parseInt(sc.next());
    int K = Integer.parseInt(sc.next());
    
    int ans = 0;
    int count = 0;
    for(int i = 100; i >= 1; i--){
      if(A%i == 0 && B%i == 0){
        ans = i;
        count++;
      }
      if(count == K){
        break;
      }
    }
    
    System.out.println(ans);
  } main {
    Scanner sc = new Scanner(System.in);
    int A = Integer.parseInt(sc.next());
    int B = Integer.parseInt(sc.next());
    int K = Integer.parseInt(sc.next());
    
    int ans = 0;
    int count = 0;
    for(int i = 100; i >= 1; i--){
      if(A%i == 0 && B%i == 0){
        ans = i;
        count++;
      }
      if(count == K){
        break;
      }
    }
    
    System.out.println(ans);
  } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int A = Integer.parseInt(sc.next()); A Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int B = Integer.parseInt(sc.next()); B Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int K = Integer.parseInt(sc.next()); K Integer.parseInt(sc.next()) Integer.parseInt Integer sc.next() sc.next sc int ans = 0; ans 0 int count = 0; count 0 for(int i = 100; i >= 1; i--){
      if(A%i == 0 && B%i == 0){
        ans = i;
        count++;
      }
      if(count == K){
        break;
      }
    } int i = 100; int i = 100; i 100 i >= 1 i 1 i-- i-- i {
      if(A%i == 0 && B%i == 0){
        ans = i;
        count++;
      }
      if(count == K){
        break;
      }
    } {
      if(A%i == 0 && B%i == 0){
        ans = i;
        count++;
      }
      if(count == K){
        break;
      }
    } if(A%i == 0 && B%i == 0){
        ans = i;
        count++;
      } A%i == 0 && B%i == 0 A%i == 0 A%i A i 0 B%i == 0 B%i B i 0 {
        ans = i;
        count++;
      } ans = i ans i count++ count if(count == K){
        break;
      } count == K count K {
        break;
      } 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){
    Scanner sc = new Scanner(System.in);
    int A = Integer.parseInt(sc.next());
    int B = Integer.parseInt(sc.next());
    int K = Integer.parseInt(sc.next());
    
    int ans = 0;
    int count = 0;
    for(int i = 100; i >= 1; i--){
      if(A%i == 0 && B%i == 0){
        ans = i;
        count++;
      }
      if(count == K){
        break;
      }
    }
    
    System.out.println(ans);
  }
} public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int A = Integer.parseInt(sc.next());
    int B = Integer.parseInt(sc.next());
    int K = Integer.parseInt(sc.next());
    
    int ans = 0;
    int count = 0;
    for(int i = 100; i >= 1; i--){
      if(A%i == 0 && B%i == 0){
        ans = i;
        count++;
      }
      if(count == K){
        break;
      }
    }
    
    System.out.println(ans);
  }
} Main
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int A = Integer.parseInt(sc.next());
    int B = Integer.parseInt(sc.next());
    int K = Integer.parseInt(sc.next());
    
    int ans = 0;
    int count = 0;
    for(int i = 100; i >= 1; i--){
      if(A%i == 0 && B%i == 0){
        ans = i;
        count++;
      }
      if(count == K){
        break;
      }
    }
    
    System.out.println(ans);
  }
}