import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.*;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

public class Main {
    static class pair implements Comparable<pair>{
        int x,id;
        pair(int a,int b){
            x=a;
            id=b;
        }
        public int compareTo(pair o) {

            return x-o.x==0?id-o.id:x-o.x;
        }
        public String toString(){
            return x+" "+id;
        }
    }
    static ArrayList<Integer> primes;
    static int[] isComposite;
    static HashMap<Integer,Integer>[]pr;
    static void sieve(int N)	// O(N log log N)
    {
        isComposite = new int[N+1];
        isComposite[0] = isComposite[1] = 1;			// 0 indicates a prime number
        primes = new ArrayList<Integer>();

        for (int i = 2; i <= N; ++i) {                //can loop till i*i <= N if primes array is not needed O(N log log sqrt(N))
            if (isComposite[i] == 0)                    //can loop in 2 and odd integers for slightly better performance
            {
                primes.add(i);
                pr[i].put(i,1);
                for (int j = i * 2; j <= N; j += i)    // j = i * 2 will not affect performance too much, may alter in modified sieve
                {
                    isComposite[j] = 1;
                    int x = j;
                    int e = 0;
                    while (x % i == 0) {
                        x /= i;
                        e++;
                    }
                    pr[j].put(i,e);
                }
            }
        }
    }
    public static void main(String[] args) throws IOException, InterruptedException {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c= sc.nextInt();
        int x=0;
        for (int i =Math.min(a,b);i>=1;i--){
            if (a%i==0&&b%i==0){
                x++;
                if (x==c)pw.println(i);
            }
        }

        pw.flush();

    }
    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if (x.charAt(0) == '-') {
                neg = true;
                start++;
            }
            for (int i = start; i < x.length(); i++)
                if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec)
                        f *= 10;
                }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg ? -1 : 1);
        }

        public boolean ready() throws IOException {
            return br.ready();
        }

    }
}
 import java.io.BufferedReader; BufferedReader java.io import java.io.IOException; IOException java.io import java.io.InputStream; InputStream java.io import java.io.InputStreamReader; InputStreamReader java.io import java.io.PrintWriter; PrintWriter java.io import java.math.BigDecimal; BigDecimal java.math import java.math.BigInteger; BigInteger java.math import java.util.Arrays; Arrays java.util import java.util.*; util.* java import java.util.PriorityQueue; PriorityQueue java.util import java.util.StringTokenizer; StringTokenizer java.util public class Main {
    static class pair implements Comparable<pair>{
        int x,id;
        pair(int a,int b){
            x=a;
            id=b;
        }
        public int compareTo(pair o) {

            return x-o.x==0?id-o.id:x-o.x;
        }
        public String toString(){
            return x+" "+id;
        }
    }
    static ArrayList<Integer> primes;
    static int[] isComposite;
    static HashMap<Integer,Integer>[]pr;
    static void sieve(int N)	// O(N log log N)
    {
        isComposite = new int[N+1];
        isComposite[0] = isComposite[1] = 1;			// 0 indicates a prime number
        primes = new ArrayList<Integer>();

        for (int i = 2; i <= N; ++i) {                //can loop till i*i <= N if primes array is not needed O(N log log sqrt(N))
            if (isComposite[i] == 0)                    //can loop in 2 and odd integers for slightly better performance
            {
                primes.add(i);
                pr[i].put(i,1);
                for (int j = i * 2; j <= N; j += i)    // j = i * 2 will not affect performance too much, may alter in modified sieve
                {
                    isComposite[j] = 1;
                    int x = j;
                    int e = 0;
                    while (x % i == 0) {
                        x /= i;
                        e++;
                    }
                    pr[j].put(i,e);
                }
            }
        }
    }
    public static void main(String[] args) throws IOException, InterruptedException {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c= sc.nextInt();
        int x=0;
        for (int i =Math.min(a,b);i>=1;i--){
            if (a%i==0&&b%i==0){
                x++;
                if (x==c)pw.println(i);
            }
        }

        pw.flush();

    }
    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if (x.charAt(0) == '-') {
                neg = true;
                start++;
            }
            for (int i = start; i < x.length(); i++)
                if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec)
                        f *= 10;
                }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg ? -1 : 1);
        }

        public boolean ready() throws IOException {
            return br.ready();
        }

    }
} Main static ArrayList<Integer> primes; primes static int[] isComposite; isComposite static HashMap<Integer,Integer>[]pr; pr static void sieve(int N)	// O(N log log N)
    {
        isComposite = new int[N+1];
        isComposite[0] = isComposite[1] = 1;			// 0 indicates a prime number
        primes = new ArrayList<Integer>();

        for (int i = 2; i <= N; ++i) {                //can loop till i*i <= N if primes array is not needed O(N log log sqrt(N))
            if (isComposite[i] == 0)                    //can loop in 2 and odd integers for slightly better performance
            {
                primes.add(i);
                pr[i].put(i,1);
                for (int j = i * 2; j <= N; j += i)    // j = i * 2 will not affect performance too much, may alter in modified sieve
                {
                    isComposite[j] = 1;
                    int x = j;
                    int e = 0;
                    while (x % i == 0) {
                        x /= i;
                        e++;
                    }
                    pr[j].put(i,e);
                }
            }
        }
    } sieve {
        isComposite = new int[N+1];
        isComposite[0] = isComposite[1] = 1;			// 0 indicates a prime number
        primes = new ArrayList<Integer>();

        for (int i = 2; i <= N; ++i) {                //can loop till i*i <= N if primes array is not needed O(N log log sqrt(N))
            if (isComposite[i] == 0)                    //can loop in 2 and odd integers for slightly better performance
            {
                primes.add(i);
                pr[i].put(i,1);
                for (int j = i * 2; j <= N; j += i)    // j = i * 2 will not affect performance too much, may alter in modified sieve
                {
                    isComposite[j] = 1;
                    int x = j;
                    int e = 0;
                    while (x % i == 0) {
                        x /= i;
                        e++;
                    }
                    pr[j].put(i,e);
                }
            }
        }
    } isComposite = new int[N+1] isComposite new int[N+1] N+1 N 1 isComposite[0] = isComposite[1] = 1 isComposite[0] isComposite 0 isComposite[1] = 1 isComposite[1] isComposite 1 1 primes = new ArrayList<Integer>() primes new ArrayList<Integer>() for (int i = 2; i <= N; ++i) {                //can loop till i*i <= N if primes array is not needed O(N log log sqrt(N))
            if (isComposite[i] == 0)                    //can loop in 2 and odd integers for slightly better performance
            {
                primes.add(i);
                pr[i].put(i,1);
                for (int j = i * 2; j <= N; j += i)    // j = i * 2 will not affect performance too much, may alter in modified sieve
                {
                    isComposite[j] = 1;
                    int x = j;
                    int e = 0;
                    while (x % i == 0) {
                        x /= i;
                        e++;
                    }
                    pr[j].put(i,e);
                }
            }
        } int i = 2; int i = 2; i 2 i <= N i N ++i ++i i {                //can loop till i*i <= N if primes array is not needed O(N log log sqrt(N))
            if (isComposite[i] == 0)                    //can loop in 2 and odd integers for slightly better performance
            {
                primes.add(i);
                pr[i].put(i,1);
                for (int j = i * 2; j <= N; j += i)    // j = i * 2 will not affect performance too much, may alter in modified sieve
                {
                    isComposite[j] = 1;
                    int x = j;
                    int e = 0;
                    while (x % i == 0) {
                        x /= i;
                        e++;
                    }
                    pr[j].put(i,e);
                }
            }
        } {                //can loop till i*i <= N if primes array is not needed O(N log log sqrt(N))
            if (isComposite[i] == 0)                    //can loop in 2 and odd integers for slightly better performance
            {
                primes.add(i);
                pr[i].put(i,1);
                for (int j = i * 2; j <= N; j += i)    // j = i * 2 will not affect performance too much, may alter in modified sieve
                {
                    isComposite[j] = 1;
                    int x = j;
                    int e = 0;
                    while (x % i == 0) {
                        x /= i;
                        e++;
                    }
                    pr[j].put(i,e);
                }
            }
        } if (isComposite[i] == 0)                    //can loop in 2 and odd integers for slightly better performance
            {
                primes.add(i);
                pr[i].put(i,1);
                for (int j = i * 2; j <= N; j += i)    // j = i * 2 will not affect performance too much, may alter in modified sieve
                {
                    isComposite[j] = 1;
                    int x = j;
                    int e = 0;
                    while (x % i == 0) {
                        x /= i;
                        e++;
                    }
                    pr[j].put(i,e);
                }
            } isComposite[i] == 0 isComposite[i] isComposite i 0 {
                primes.add(i);
                pr[i].put(i,1);
                for (int j = i * 2; j <= N; j += i)    // j = i * 2 will not affect performance too much, may alter in modified sieve
                {
                    isComposite[j] = 1;
                    int x = j;
                    int e = 0;
                    while (x % i == 0) {
                        x /= i;
                        e++;
                    }
                    pr[j].put(i,e);
                }
            } primes.add(i) primes.add primes i pr[i].put(i,1) pr[i].put pr[i] pr i i 1 for (int j = i * 2; j <= N; j += i)    // j = i * 2 will not affect performance too much, may alter in modified sieve
                {
                    isComposite[j] = 1;
                    int x = j;
                    int e = 0;
                    while (x % i == 0) {
                        x /= i;
                        e++;
                    }
                    pr[j].put(i,e);
                } int j = i * 2; int j = i * 2; j i * 2 i 2 j <= N j N j += i j += i j i {
                    isComposite[j] = 1;
                    int x = j;
                    int e = 0;
                    while (x % i == 0) {
                        x /= i;
                        e++;
                    }
                    pr[j].put(i,e);
                } {
                    isComposite[j] = 1;
                    int x = j;
                    int e = 0;
                    while (x % i == 0) {
                        x /= i;
                        e++;
                    }
                    pr[j].put(i,e);
                } isComposite[j] = 1 isComposite[j] isComposite j 1 int x = j; x j int e = 0; e 0 while (x % i == 0) {
                        x /= i;
                        e++;
                    } x % i == 0 x % i x i 0 {
                        x /= i;
                        e++;
                    } x /= i x i e++ e pr[j].put(i,e) pr[j].put pr[j] pr j i e int N N public static void main(String[] args) throws IOException, InterruptedException {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c= sc.nextInt();
        int x=0;
        for (int i =Math.min(a,b);i>=1;i--){
            if (a%i==0&&b%i==0){
                x++;
                if (x==c)pw.println(i);
            }
        }

        pw.flush();

    } main {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c= sc.nextInt();
        int x=0;
        for (int i =Math.min(a,b);i>=1;i--){
            if (a%i==0&&b%i==0){
                x++;
                if (x==c)pw.println(i);
            }
        }

        pw.flush();

    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) PrintWriter pw = new PrintWriter(System.out); pw new PrintWriter(System.out) int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc int b = sc.nextInt(); b sc.nextInt() sc.nextInt sc int c= sc.nextInt(); c sc.nextInt() sc.nextInt sc int x=0; x 0 for (int i =Math.min(a,b);i>=1;i--){
            if (a%i==0&&b%i==0){
                x++;
                if (x==c)pw.println(i);
            }
        } int i =Math.min(a,b); int i =Math.min(a,b); i Math.min(a,b) Math.min Math a b i>=1 i 1 i-- i-- i {
            if (a%i==0&&b%i==0){
                x++;
                if (x==c)pw.println(i);
            }
        } {
            if (a%i==0&&b%i==0){
                x++;
                if (x==c)pw.println(i);
            }
        } if (a%i==0&&b%i==0){
                x++;
                if (x==c)pw.println(i);
            } a%i==0&&b%i==0 a%i==0 a%i a i 0 b%i==0 b%i b i 0 {
                x++;
                if (x==c)pw.println(i);
            } x++ x if (x==c)pw.println(i); x==c x c pw.println(i) pw.println pw i pw.flush() pw.flush pw String[] args args static class pair implements Comparable<pair>{
        int x,id;
        pair(int a,int b){
            x=a;
            id=b;
        }
        public int compareTo(pair o) {

            return x-o.x==0?id-o.id:x-o.x;
        }
        public String toString(){
            return x+" "+id;
        }
    } pair int x x id; id pair(int a,int b){
            x=a;
            id=b;
        } pair {
            x=a;
            id=b;
        } x=a x a id=b id b int a a int b b public int compareTo(pair o) {

            return x-o.x==0?id-o.id:x-o.x;
        } compareTo {

            return x-o.x==0?id-o.id:x-o.x;
        } return x-o.x==0?id-o.id:x-o.x; x-o.x==0?id-o.id:x-o.x x-o.x==0 x-o.x x o.x o o.x 0 id-o.id id o.id o o.id x-o.x x o.x o o.x pair o o public String toString(){
            return x+" "+id;
        } toString {
            return x+" "+id;
        } return x+" "+id; x+" "+id x+" "+id x " " id Comparable static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if (x.charAt(0) == '-') {
                neg = true;
                start++;
            }
            for (int i = start; i < x.length(); i++)
                if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec)
                        f *= 10;
                }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg ? -1 : 1);
        }

        public boolean ready() throws IOException {
            return br.ready();
        }

    } Scanner StringTokenizer st; st BufferedReader br; br public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        } Scanner {
            br = new BufferedReader(new InputStreamReader(s));
        } br = new BufferedReader(new InputStreamReader(s)) br new BufferedReader(new InputStreamReader(s)) InputStream s s public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        } next {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        } while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine()); st == null || !st.hasMoreTokens() st == null st null !st.hasMoreTokens() st.hasMoreTokens() st.hasMoreTokens st st = new StringTokenizer(br.readLine()) st new StringTokenizer(br.readLine()) return st.nextToken(); st.nextToken() st.nextToken st public int nextInt() throws IOException {
            return Integer.parseInt(next());
        } nextInt {
            return Integer.parseInt(next());
        } return Integer.parseInt(next()); Integer.parseInt(next()) Integer.parseInt Integer next() next public long nextLong() throws IOException {
            return Long.parseLong(next());
        } nextLong {
            return Long.parseLong(next());
        } return Long.parseLong(next()); Long.parseLong(next()) Long.parseLong Long next() next public String nextLine() throws IOException {
            return br.readLine();
        } nextLine {
            return br.readLine();
        } return br.readLine(); br.readLine() br.readLine br public double nextDouble() throws IOException {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if (x.charAt(0) == '-') {
                neg = true;
                start++;
            }
            for (int i = start; i < x.length(); i++)
                if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec)
                        f *= 10;
                }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg ? -1 : 1);
        } nextDouble {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if (x.charAt(0) == '-') {
                neg = true;
                start++;
            }
            for (int i = start; i < x.length(); i++)
                if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec)
                        f *= 10;
                }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg ? -1 : 1);
        } String x = next(); x next() next StringBuilder sb = new StringBuilder("0"); sb new StringBuilder("0") double res = 0 res 0 f = 1; f 1 boolean dec = false dec false neg = false; neg false int start = 0; start 0 if (x.charAt(0) == '-') {
                neg = true;
                start++;
            } x.charAt(0) == '-' x.charAt(0) x.charAt x 0 '-' {
                neg = true;
                start++;
            } neg = true neg true start++ start for (int i = start; i < x.length(); i++)
                if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec)
                        f *= 10;
                } int i = start; int i = start; i start i < x.length() i x.length() x.length x i++ i++ i if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec)
                        f *= 10;
                } if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec)
                        f *= 10;
                } x.charAt(i) == '.' x.charAt(i) x.charAt x i '.' {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } res = Long.parseLong(sb.toString()) res Long.parseLong(sb.toString()) Long.parseLong Long sb.toString() sb.toString sb sb = new StringBuilder("0") sb new StringBuilder("0") dec = true dec true {
                    sb.append(x.charAt(i));
                    if (dec)
                        f *= 10;
                } sb.append(x.charAt(i)) sb.append sb x.charAt(i) x.charAt x i if (dec)
                        f *= 10; dec f *= 10 f 10 res += Long.parseLong(sb.toString()) / f res Long.parseLong(sb.toString()) / f Long.parseLong(sb.toString()) Long.parseLong Long sb.toString() sb.toString sb f return res * (neg ? -1 : 1); res * (neg ? -1 : 1) res (neg ? -1 : 1) neg -1 1 1 public boolean ready() throws IOException {
            return br.ready();
        } ready {
            return br.ready();
        } return br.ready(); br.ready() br.ready br public class Main {
    static class pair implements Comparable<pair>{
        int x,id;
        pair(int a,int b){
            x=a;
            id=b;
        }
        public int compareTo(pair o) {

            return x-o.x==0?id-o.id:x-o.x;
        }
        public String toString(){
            return x+" "+id;
        }
    }
    static ArrayList<Integer> primes;
    static int[] isComposite;
    static HashMap<Integer,Integer>[]pr;
    static void sieve(int N)	// O(N log log N)
    {
        isComposite = new int[N+1];
        isComposite[0] = isComposite[1] = 1;			// 0 indicates a prime number
        primes = new ArrayList<Integer>();

        for (int i = 2; i <= N; ++i) {                //can loop till i*i <= N if primes array is not needed O(N log log sqrt(N))
            if (isComposite[i] == 0)                    //can loop in 2 and odd integers for slightly better performance
            {
                primes.add(i);
                pr[i].put(i,1);
                for (int j = i * 2; j <= N; j += i)    // j = i * 2 will not affect performance too much, may alter in modified sieve
                {
                    isComposite[j] = 1;
                    int x = j;
                    int e = 0;
                    while (x % i == 0) {
                        x /= i;
                        e++;
                    }
                    pr[j].put(i,e);
                }
            }
        }
    }
    public static void main(String[] args) throws IOException, InterruptedException {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c= sc.nextInt();
        int x=0;
        for (int i =Math.min(a,b);i>=1;i--){
            if (a%i==0&&b%i==0){
                x++;
                if (x==c)pw.println(i);
            }
        }

        pw.flush();

    }
    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if (x.charAt(0) == '-') {
                neg = true;
                start++;
            }
            for (int i = start; i < x.length(); i++)
                if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec)
                        f *= 10;
                }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg ? -1 : 1);
        }

        public boolean ready() throws IOException {
            return br.ready();
        }

    }
} public class Main {
    static class pair implements Comparable<pair>{
        int x,id;
        pair(int a,int b){
            x=a;
            id=b;
        }
        public int compareTo(pair o) {

            return x-o.x==0?id-o.id:x-o.x;
        }
        public String toString(){
            return x+" "+id;
        }
    }
    static ArrayList<Integer> primes;
    static int[] isComposite;
    static HashMap<Integer,Integer>[]pr;
    static void sieve(int N)	// O(N log log N)
    {
        isComposite = new int[N+1];
        isComposite[0] = isComposite[1] = 1;			// 0 indicates a prime number
        primes = new ArrayList<Integer>();

        for (int i = 2; i <= N; ++i) {                //can loop till i*i <= N if primes array is not needed O(N log log sqrt(N))
            if (isComposite[i] == 0)                    //can loop in 2 and odd integers for slightly better performance
            {
                primes.add(i);
                pr[i].put(i,1);
                for (int j = i * 2; j <= N; j += i)    // j = i * 2 will not affect performance too much, may alter in modified sieve
                {
                    isComposite[j] = 1;
                    int x = j;
                    int e = 0;
                    while (x % i == 0) {
                        x /= i;
                        e++;
                    }
                    pr[j].put(i,e);
                }
            }
        }
    }
    public static void main(String[] args) throws IOException, InterruptedException {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c= sc.nextInt();
        int x=0;
        for (int i =Math.min(a,b);i>=1;i--){
            if (a%i==0&&b%i==0){
                x++;
                if (x==c)pw.println(i);
            }
        }

        pw.flush();

    }
    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if (x.charAt(0) == '-') {
                neg = true;
                start++;
            }
            for (int i = start; i < x.length(); i++)
                if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec)
                        f *= 10;
                }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg ? -1 : 1);
        }

        public boolean ready() throws IOException {
            return br.ready();
        }

    }
} Main
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.*;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

public class Main {
    static class pair implements Comparable<pair>{
        int x,id;
        pair(int a,int b){
            x=a;
            id=b;
        }
        public int compareTo(pair o) {

            return x-o.x==0?id-o.id:x-o.x;
        }
        public String toString(){
            return x+" "+id;
        }
    }
    static ArrayList<Integer> primes;
    static int[] isComposite;
    static HashMap<Integer,Integer>[]pr;
    static void sieve(int N)	// O(N log log N)
    {
        isComposite = new int[N+1];
        isComposite[0] = isComposite[1] = 1;			// 0 indicates a prime number
        primes = new ArrayList<Integer>();

        for (int i = 2; i <= N; ++i) {                //can loop till i*i <= N if primes array is not needed O(N log log sqrt(N))
            if (isComposite[i] == 0)                    //can loop in 2 and odd integers for slightly better performance
            {
                primes.add(i);
                pr[i].put(i,1);
                for (int j = i * 2; j <= N; j += i)    // j = i * 2 will not affect performance too much, may alter in modified sieve
                {
                    isComposite[j] = 1;
                    int x = j;
                    int e = 0;
                    while (x % i == 0) {
                        x /= i;
                        e++;
                    }
                    pr[j].put(i,e);
                }
            }
        }
    }
    public static void main(String[] args) throws IOException, InterruptedException {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c= sc.nextInt();
        int x=0;
        for (int i =Math.min(a,b);i>=1;i--){
            if (a%i==0&&b%i==0){
                x++;
                if (x==c)pw.println(i);
            }
        }

        pw.flush();

    }
    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if (x.charAt(0) == '-') {
                neg = true;
                start++;
            }
            for (int i = start; i < x.length(); i++)
                if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec)
                        f *= 10;
                }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg ? -1 : 1);
        }

        public boolean ready() throws IOException {
            return br.ready();
        }

    }
}

