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());
        List<Integer> list = new ArrayList<>();
        for(int i = min(a, b); i > 0; i--) {
            if(a % i == 0 && b % i == 0) {
                list.add(i);
            }
        }
        System.out.println(list.get(k-1));
    }
    
    public static int min(int a, int b) {
        if(a <= b) {
            return a;
        }else {
            return b;
        }
    }
} 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());
        List<Integer> list = new ArrayList<>();
        for(int i = min(a, b); i > 0; i--) {
            if(a % i == 0 && b % i == 0) {
                list.add(i);
            }
        }
        System.out.println(list.get(k-1));
    }
    
    public static int min(int a, int b) {
        if(a <= b) {
            return a;
        }else {
            return b;
        }
    }
} 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());
        List<Integer> list = new ArrayList<>();
        for(int i = min(a, b); i > 0; i--) {
            if(a % i == 0 && b % i == 0) {
                list.add(i);
            }
        }
        System.out.println(list.get(k-1));
    } 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());
        List<Integer> list = new ArrayList<>();
        for(int i = min(a, b); i > 0; i--) {
            if(a % i == 0 && b % i == 0) {
                list.add(i);
            }
        }
        System.out.println(list.get(k-1));
    } 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 List<Integer> list = new ArrayList<>(); list new ArrayList<>() for(int i = min(a, b); i > 0; i--) {
            if(a % i == 0 && b % i == 0) {
                list.add(i);
            }
        } int i = min(a, b); int i = min(a, b); i min(a, b) min a b i > 0 i 0 i-- i-- i {
            if(a % i == 0 && b % i == 0) {
                list.add(i);
            }
        } {
            if(a % i == 0 && b % i == 0) {
                list.add(i);
            }
        } if(a % i == 0 && b % i == 0) {
                list.add(i);
            } a % i == 0 && b % i == 0 a % i == 0 a % i a i 0 b % i == 0 b % i b i 0 {
                list.add(i);
            } list.add(i) list.add list i System.out.println(list.get(k-1)) System.out.println System.out System System.out list.get(k-1) list.get list k-1 k 1 String[] args args public static int min(int a, int b) {
        if(a <= b) {
            return a;
        }else {
            return b;
        }
    } min {
        if(a <= b) {
            return a;
        }else {
            return b;
        }
    } if(a <= b) {
            return a;
        }else {
            return b;
        } a <= b a b {
            return a;
        } return a; a {
            return b;
        } return b; b int a a int b b 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());
        List<Integer> list = new ArrayList<>();
        for(int i = min(a, b); i > 0; i--) {
            if(a % i == 0 && b % i == 0) {
                list.add(i);
            }
        }
        System.out.println(list.get(k-1));
    }
    
    public static int min(int a, int b) {
        if(a <= b) {
            return a;
        }else {
            return b;
        }
    }
} 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());
        List<Integer> list = new ArrayList<>();
        for(int i = min(a, b); i > 0; i--) {
            if(a % i == 0 && b % i == 0) {
                list.add(i);
            }
        }
        System.out.println(list.get(k-1));
    }
    
    public static int min(int a, int b) {
        if(a <= b) {
            return a;
        }else {
            return b;
        }
    }
} 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());
        List<Integer> list = new ArrayList<>();
        for(int i = min(a, b); i > 0; i--) {
            if(a % i == 0 && b % i == 0) {
                list.add(i);
            }
        }
        System.out.println(list.get(k-1));
    }
    
    public static int min(int a, int b) {
        if(a <= b) {
            return a;
        }else {
            return b;
        }
    }
}
