import java.util.*;
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 cnt = 0;
    for(int i = Math.max(A,B); i>=1; i--){
      if(A%i == 0 && B%i==0){
        cnt++;
        if(cnt == K){
          System.out.println(i);
          break;
        }
      }
    }
  }
} import java.util.*; util.* java 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 cnt = 0;
    for(int i = Math.max(A,B); i>=1; i--){
      if(A%i == 0 && B%i==0){
        cnt++;
        if(cnt == K){
          System.out.println(i);
          break;
        }
      }
    }
  }
} 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 cnt = 0;
    for(int i = Math.max(A,B); i>=1; i--){
      if(A%i == 0 && B%i==0){
        cnt++;
        if(cnt == K){
          System.out.println(i);
          break;
        }
      }
    }
  } main {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int K = sc.nextInt();
    int cnt = 0;
    for(int i = Math.max(A,B); i>=1; i--){
      if(A%i == 0 && B%i==0){
        cnt++;
        if(cnt == K){
          System.out.println(i);
          break;
        }
      }
    }
  } 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 cnt = 0; cnt 0 for(int i = Math.max(A,B); i>=1; i--){
      if(A%i == 0 && B%i==0){
        cnt++;
        if(cnt == K){
          System.out.println(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>=1 i 1 i-- i-- i {
      if(A%i == 0 && B%i==0){
        cnt++;
        if(cnt == K){
          System.out.println(i);
          break;
        }
      }
    } {
      if(A%i == 0 && B%i==0){
        cnt++;
        if(cnt == K){
          System.out.println(i);
          break;
        }
      }
    } if(A%i == 0 && B%i==0){
        cnt++;
        if(cnt == K){
          System.out.println(i);
          break;
        }
      } A%i == 0 && B%i==0 A%i == 0 A%i A i 0 B%i==0 B%i B i 0 {
        cnt++;
        if(cnt == K){
          System.out.println(i);
          break;
        }
      } cnt++ cnt if(cnt == K){
          System.out.println(i);
          break;
        } cnt == K cnt K {
          System.out.println(i);
          break;
        } System.out.println(i) System.out.println System.out System System.out i break; String[] args args
import java.util.*;
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 cnt = 0;
    for(int i = Math.max(A,B); i>=1; i--){
      if(A%i == 0 && B%i==0){
        cnt++;
        if(cnt == K){
          System.out.println(i);
          break;
        }
      }
    }
  }
}
