import java.util.*;

import javax.swing.text.AbstractDocument.BranchElement;

import com.sun.org.apache.xpath.internal.SourceTree;

public 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();
        Set<Integer> ans1 = new TreeSet<>();
        for (int i = 1; i <= a; i++) {
            if (a % i == 0) {
                ans1.add(i);
            }
        }
        Set<Integer> ans2 = new TreeSet<>();
        for (int i = 1; i <= b; i++) {
            if (b % i == 0) {
                ans2.add(i);
            }
        }
        List<Integer> result = new ArrayList<>();
        for (Integer val1 : ans1) {
            for (Integer val2 : ans2) {
                if (val1 == val2) {
                    result.add(val1);
                }
                if (val1 <= val2) {
                    break;
                }
            }
        }
        System.out.println(result.get(result.size() - k));
    }
} import java.util.*; util.* java import javax.swing.text.AbstractDocument.BranchElement; BranchElement javax.swing.text.AbstractDocument import com.sun.org.apache.xpath.internal.SourceTree; SourceTree com.sun.org.apache.xpath.internal public 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();
        Set<Integer> ans1 = new TreeSet<>();
        for (int i = 1; i <= a; i++) {
            if (a % i == 0) {
                ans1.add(i);
            }
        }
        Set<Integer> ans2 = new TreeSet<>();
        for (int i = 1; i <= b; i++) {
            if (b % i == 0) {
                ans2.add(i);
            }
        }
        List<Integer> result = new ArrayList<>();
        for (Integer val1 : ans1) {
            for (Integer val2 : ans2) {
                if (val1 == val2) {
                    result.add(val1);
                }
                if (val1 <= val2) {
                    break;
                }
            }
        }
        System.out.println(result.get(result.size() - k));
    }
} 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();
        Set<Integer> ans1 = new TreeSet<>();
        for (int i = 1; i <= a; i++) {
            if (a % i == 0) {
                ans1.add(i);
            }
        }
        Set<Integer> ans2 = new TreeSet<>();
        for (int i = 1; i <= b; i++) {
            if (b % i == 0) {
                ans2.add(i);
            }
        }
        List<Integer> result = new ArrayList<>();
        for (Integer val1 : ans1) {
            for (Integer val2 : ans2) {
                if (val1 == val2) {
                    result.add(val1);
                }
                if (val1 <= val2) {
                    break;
                }
            }
        }
        System.out.println(result.get(result.size() - k));
    } main {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        Set<Integer> ans1 = new TreeSet<>();
        for (int i = 1; i <= a; i++) {
            if (a % i == 0) {
                ans1.add(i);
            }
        }
        Set<Integer> ans2 = new TreeSet<>();
        for (int i = 1; i <= b; i++) {
            if (b % i == 0) {
                ans2.add(i);
            }
        }
        List<Integer> result = new ArrayList<>();
        for (Integer val1 : ans1) {
            for (Integer val2 : ans2) {
                if (val1 == val2) {
                    result.add(val1);
                }
                if (val1 <= val2) {
                    break;
                }
            }
        }
        System.out.println(result.get(result.size() - k));
    } 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 Set<Integer> ans1 = new TreeSet<>(); ans1 new TreeSet<>() for (int i = 1; i <= a; i++) {
            if (a % i == 0) {
                ans1.add(i);
            }
        } int i = 1; int i = 1; i 1 i <= a i a i++ i++ i {
            if (a % i == 0) {
                ans1.add(i);
            }
        } {
            if (a % i == 0) {
                ans1.add(i);
            }
        } if (a % i == 0) {
                ans1.add(i);
            } a % i == 0 a % i a i 0 {
                ans1.add(i);
            } ans1.add(i) ans1.add ans1 i Set<Integer> ans2 = new TreeSet<>(); ans2 new TreeSet<>() for (int i = 1; i <= b; i++) {
            if (b % i == 0) {
                ans2.add(i);
            }
        } int i = 1; int i = 1; i 1 i <= b i b i++ i++ i {
            if (b % i == 0) {
                ans2.add(i);
            }
        } {
            if (b % i == 0) {
                ans2.add(i);
            }
        } if (b % i == 0) {
                ans2.add(i);
            } b % i == 0 b % i b i 0 {
                ans2.add(i);
            } ans2.add(i) ans2.add ans2 i List<Integer> result = new ArrayList<>(); result new ArrayList<>() for (Integer val1 : ans1) {
            for (Integer val2 : ans2) {
                if (val1 == val2) {
                    result.add(val1);
                }
                if (val1 <= val2) {
                    break;
                }
            }
        } Integer val1 ans1 {
            for (Integer val2 : ans2) {
                if (val1 == val2) {
                    result.add(val1);
                }
                if (val1 <= val2) {
                    break;
                }
            }
        } {
            for (Integer val2 : ans2) {
                if (val1 == val2) {
                    result.add(val1);
                }
                if (val1 <= val2) {
                    break;
                }
            }
        } for (Integer val2 : ans2) {
                if (val1 == val2) {
                    result.add(val1);
                }
                if (val1 <= val2) {
                    break;
                }
            } Integer val2 ans2 {
                if (val1 == val2) {
                    result.add(val1);
                }
                if (val1 <= val2) {
                    break;
                }
            } {
                if (val1 == val2) {
                    result.add(val1);
                }
                if (val1 <= val2) {
                    break;
                }
            } if (val1 == val2) {
                    result.add(val1);
                } val1 == val2 val1 val2 {
                    result.add(val1);
                } result.add(val1) result.add result val1 if (val1 <= val2) {
                    break;
                } val1 <= val2 val1 val2 {
                    break;
                } break; System.out.println(result.get(result.size() - k)) System.out.println System.out System System.out result.get(result.size() - k) result.get result result.size() - k result.size() result.size result k String args[] args public 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();
        Set<Integer> ans1 = new TreeSet<>();
        for (int i = 1; i <= a; i++) {
            if (a % i == 0) {
                ans1.add(i);
            }
        }
        Set<Integer> ans2 = new TreeSet<>();
        for (int i = 1; i <= b; i++) {
            if (b % i == 0) {
                ans2.add(i);
            }
        }
        List<Integer> result = new ArrayList<>();
        for (Integer val1 : ans1) {
            for (Integer val2 : ans2) {
                if (val1 == val2) {
                    result.add(val1);
                }
                if (val1 <= val2) {
                    break;
                }
            }
        }
        System.out.println(result.get(result.size() - k));
    }
} public 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();
        Set<Integer> ans1 = new TreeSet<>();
        for (int i = 1; i <= a; i++) {
            if (a % i == 0) {
                ans1.add(i);
            }
        }
        Set<Integer> ans2 = new TreeSet<>();
        for (int i = 1; i <= b; i++) {
            if (b % i == 0) {
                ans2.add(i);
            }
        }
        List<Integer> result = new ArrayList<>();
        for (Integer val1 : ans1) {
            for (Integer val2 : ans2) {
                if (val1 == val2) {
                    result.add(val1);
                }
                if (val1 <= val2) {
                    break;
                }
            }
        }
        System.out.println(result.get(result.size() - k));
    }
} Main
import java.util.*;

import javax.swing.text.AbstractDocument.BranchElement;

import com.sun.org.apache.xpath.internal.SourceTree;

public 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();
        Set<Integer> ans1 = new TreeSet<>();
        for (int i = 1; i <= a; i++) {
            if (a % i == 0) {
                ans1.add(i);
            }
        }
        Set<Integer> ans2 = new TreeSet<>();
        for (int i = 1; i <= b; i++) {
            if (b % i == 0) {
                ans2.add(i);
            }
        }
        List<Integer> result = new ArrayList<>();
        for (Integer val1 : ans1) {
            for (Integer val2 : ans2) {
                if (val1 == val2) {
                    result.add(val1);
                }
                if (val1 <= val2) {
                    break;
                }
            }
        }
        System.out.println(result.get(result.size() - k));
    }
}
