import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        int A = scn.nextInt();
        int B = scn.nextInt();
        int K = scn.nextInt();
        ArrayList<Integer> hits = new ArrayList<Integer>();
        int cnt = 0;
        for(int i=1; i<=100; i++) {
            if(A%i == 0 && B%i == 0) hits.add(i);
        }
        System.out.println(hits.get(hits.size() - K));
        scn.close();
    }
} import java.util.ArrayList; ArrayList java.util import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        int A = scn.nextInt();
        int B = scn.nextInt();
        int K = scn.nextInt();
        ArrayList<Integer> hits = new ArrayList<Integer>();
        int cnt = 0;
        for(int i=1; i<=100; i++) {
            if(A%i == 0 && B%i == 0) hits.add(i);
        }
        System.out.println(hits.get(hits.size() - K));
        scn.close();
    }
} Main public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        int A = scn.nextInt();
        int B = scn.nextInt();
        int K = scn.nextInt();
        ArrayList<Integer> hits = new ArrayList<Integer>();
        int cnt = 0;
        for(int i=1; i<=100; i++) {
            if(A%i == 0 && B%i == 0) hits.add(i);
        }
        System.out.println(hits.get(hits.size() - K));
        scn.close();
    } main {
        Scanner scn = new Scanner(System.in);
        int A = scn.nextInt();
        int B = scn.nextInt();
        int K = scn.nextInt();
        ArrayList<Integer> hits = new ArrayList<Integer>();
        int cnt = 0;
        for(int i=1; i<=100; i++) {
            if(A%i == 0 && B%i == 0) hits.add(i);
        }
        System.out.println(hits.get(hits.size() - K));
        scn.close();
    } Scanner scn = new Scanner(System.in); scn new Scanner(System.in) int A = scn.nextInt(); A scn.nextInt() scn.nextInt scn int B = scn.nextInt(); B scn.nextInt() scn.nextInt scn int K = scn.nextInt(); K scn.nextInt() scn.nextInt scn ArrayList<Integer> hits = new ArrayList<Integer>(); hits new ArrayList<Integer>() int cnt = 0; cnt 0 for(int i=1; i<=100; i++) {
            if(A%i == 0 && B%i == 0) hits.add(i);
        } int i=1; int i=1; i 1 i<=100 i 100 i++ i++ i {
            if(A%i == 0 && B%i == 0) hits.add(i);
        } {
            if(A%i == 0 && B%i == 0) hits.add(i);
        } if(A%i == 0 && B%i == 0) hits.add(i); A%i == 0 && B%i == 0 A%i == 0 A%i A i 0 B%i == 0 B%i B i 0 hits.add(i) hits.add hits i System.out.println(hits.get(hits.size() - K)) System.out.println System.out System System.out hits.get(hits.size() - K) hits.get hits hits.size() - K hits.size() hits.size hits K scn.close() scn.close scn String[] args args public class Main {
    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        int A = scn.nextInt();
        int B = scn.nextInt();
        int K = scn.nextInt();
        ArrayList<Integer> hits = new ArrayList<Integer>();
        int cnt = 0;
        for(int i=1; i<=100; i++) {
            if(A%i == 0 && B%i == 0) hits.add(i);
        }
        System.out.println(hits.get(hits.size() - K));
        scn.close();
    }
} public class Main {
    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        int A = scn.nextInt();
        int B = scn.nextInt();
        int K = scn.nextInt();
        ArrayList<Integer> hits = new ArrayList<Integer>();
        int cnt = 0;
        for(int i=1; i<=100; i++) {
            if(A%i == 0 && B%i == 0) hits.add(i);
        }
        System.out.println(hits.get(hits.size() - K));
        scn.close();
    }
} Main
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        int A = scn.nextInt();
        int B = scn.nextInt();
        int K = scn.nextInt();
        ArrayList<Integer> hits = new ArrayList<Integer>();
        int cnt = 0;
        for(int i=1; i<=100; i++) {
            if(A%i == 0 && B%i == 0) hits.add(i);
        }
        System.out.println(hits.get(hits.size() - K));
        scn.close();
    }
}