import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
 
public class Main {
    public static void main(String args[]) {
        final Scanner lineScanner = new Scanner(System.in);
        final int A = lineScanner.nextInt();
        final int B = lineScanner.nextInt();
        final int needIndex = lineScanner.nextInt();
 
        List<Integer> numList = new ArrayList<>();
        for (int i = 1; i <= A && i <= B; i++) {
            if (A % i == 0 && B % i == 0) {
                numList.add(i);
            }
        }
        Collections.sort(numList, Collections.reverseOrder());
        System.out.println(numList.get(needIndex - 1));
    }
} import java.util.ArrayList; ArrayList java.util import java.util.Collections; Collections java.util import java.util.List; List java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String args[]) {
        final Scanner lineScanner = new Scanner(System.in);
        final int A = lineScanner.nextInt();
        final int B = lineScanner.nextInt();
        final int needIndex = lineScanner.nextInt();
 
        List<Integer> numList = new ArrayList<>();
        for (int i = 1; i <= A && i <= B; i++) {
            if (A % i == 0 && B % i == 0) {
                numList.add(i);
            }
        }
        Collections.sort(numList, Collections.reverseOrder());
        System.out.println(numList.get(needIndex - 1));
    }
} Main public static void main(String args[]) {
        final Scanner lineScanner = new Scanner(System.in);
        final int A = lineScanner.nextInt();
        final int B = lineScanner.nextInt();
        final int needIndex = lineScanner.nextInt();
 
        List<Integer> numList = new ArrayList<>();
        for (int i = 1; i <= A && i <= B; i++) {
            if (A % i == 0 && B % i == 0) {
                numList.add(i);
            }
        }
        Collections.sort(numList, Collections.reverseOrder());
        System.out.println(numList.get(needIndex - 1));
    } main {
        final Scanner lineScanner = new Scanner(System.in);
        final int A = lineScanner.nextInt();
        final int B = lineScanner.nextInt();
        final int needIndex = lineScanner.nextInt();
 
        List<Integer> numList = new ArrayList<>();
        for (int i = 1; i <= A && i <= B; i++) {
            if (A % i == 0 && B % i == 0) {
                numList.add(i);
            }
        }
        Collections.sort(numList, Collections.reverseOrder());
        System.out.println(numList.get(needIndex - 1));
    } final Scanner lineScanner = new Scanner(System.in); lineScanner new Scanner(System.in) final int A = lineScanner.nextInt(); A lineScanner.nextInt() lineScanner.nextInt lineScanner final int B = lineScanner.nextInt(); B lineScanner.nextInt() lineScanner.nextInt lineScanner final int needIndex = lineScanner.nextInt(); needIndex lineScanner.nextInt() lineScanner.nextInt lineScanner List<Integer> numList = new ArrayList<>(); numList new ArrayList<>() for (int i = 1; i <= A && i <= B; i++) {
            if (A % i == 0 && B % i == 0) {
                numList.add(i);
            }
        } int i = 1; int i = 1; i 1 i <= A && i <= B i <= A i A i <= B i B i++ i++ i {
            if (A % i == 0 && B % i == 0) {
                numList.add(i);
            }
        } {
            if (A % i == 0 && B % i == 0) {
                numList.add(i);
            }
        } if (A % i == 0 && B % i == 0) {
                numList.add(i);
            } A % i == 0 && B % i == 0 A % i == 0 A % i A i 0 B % i == 0 B % i B i 0 {
                numList.add(i);
            } numList.add(i) numList.add numList i Collections.sort(numList, Collections.reverseOrder()) Collections.sort Collections numList Collections.reverseOrder() Collections.reverseOrder Collections System.out.println(numList.get(needIndex - 1)) System.out.println System.out System System.out numList.get(needIndex - 1) numList.get numList needIndex - 1 needIndex 1 String args[] args public class Main {
    public static void main(String args[]) {
        final Scanner lineScanner = new Scanner(System.in);
        final int A = lineScanner.nextInt();
        final int B = lineScanner.nextInt();
        final int needIndex = lineScanner.nextInt();
 
        List<Integer> numList = new ArrayList<>();
        for (int i = 1; i <= A && i <= B; i++) {
            if (A % i == 0 && B % i == 0) {
                numList.add(i);
            }
        }
        Collections.sort(numList, Collections.reverseOrder());
        System.out.println(numList.get(needIndex - 1));
    }
} public class Main {
    public static void main(String args[]) {
        final Scanner lineScanner = new Scanner(System.in);
        final int A = lineScanner.nextInt();
        final int B = lineScanner.nextInt();
        final int needIndex = lineScanner.nextInt();
 
        List<Integer> numList = new ArrayList<>();
        for (int i = 1; i <= A && i <= B; i++) {
            if (A % i == 0 && B % i == 0) {
                numList.add(i);
            }
        }
        Collections.sort(numList, Collections.reverseOrder());
        System.out.println(numList.get(needIndex - 1));
    }
} Main
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
 
public class Main {
    public static void main(String args[]) {
        final Scanner lineScanner = new Scanner(System.in);
        final int A = lineScanner.nextInt();
        final int B = lineScanner.nextInt();
        final int needIndex = lineScanner.nextInt();
 
        List<Integer> numList = new ArrayList<>();
        for (int i = 1; i <= A && i <= B; i++) {
            if (A % i == 0 && B % i == 0) {
                numList.add(i);
            }
        }
        Collections.sort(numList, Collections.reverseOrder());
        System.out.println(numList.get(needIndex - 1));
    }
}