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 n = 0;
        for (int i =101; i >= 1; i--){
          if(a % i == 0 && b % i == 0){
            n++;
            if(n == k) System.out.println(i);
          }
        }
    }
} 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 n = 0;
        for (int i =101; i >= 1; i--){
          if(a % i == 0 && b % i == 0){
            n++;
            if(n == k) System.out.println(i);
          }
        }
    }
} 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 n = 0;
        for (int i =101; i >= 1; i--){
          if(a % i == 0 && b % i == 0){
            n++;
            if(n == k) System.out.println(i);
          }
        }
    } main {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        int n = 0;
        for (int i =101; i >= 1; i--){
          if(a % i == 0 && b % i == 0){
            n++;
            if(n == k) System.out.println(i);
          }
        }
    } 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 n = 0; n 0 for (int i =101; i >= 1; i--){
          if(a % i == 0 && b % i == 0){
            n++;
            if(n == k) System.out.println(i);
          }
        } int i =101; int i =101; i 101 i >= 1 i 1 i-- i-- i {
          if(a % i == 0 && b % i == 0){
            n++;
            if(n == k) System.out.println(i);
          }
        } {
          if(a % i == 0 && b % i == 0){
            n++;
            if(n == k) System.out.println(i);
          }
        } if(a % i == 0 && b % i == 0){
            n++;
            if(n == k) System.out.println(i);
          } a % i == 0 && b % i == 0 a % i == 0 a % i a i 0 b % i == 0 b % i b i 0 {
            n++;
            if(n == k) System.out.println(i);
          } n++ n if(n == k) System.out.println(i); n == k n k System.out.println(i) System.out.println System.out System System.out i 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 n = 0;
        for (int i =101; i >= 1; i--){
          if(a % i == 0 && b % i == 0){
            n++;
            if(n == k) System.out.println(i);
          }
        }
    }
}
