
import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args){
        solve();
    }

    public static void solve(){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        int x = (int)Math.min(a, b);
        while(true){
        	if(a%x==0 && b%x==0){
        		k--;
        		if(k<1){
        			break;
        		}
        	}
        	x--;
        }
        System.out.println(x);
    }
} import java.io.*; io.* java import java.util.*; util.* java class Main{
    public static void main(String[] args){
        solve();
    }

    public static void solve(){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        int x = (int)Math.min(a, b);
        while(true){
        	if(a%x==0 && b%x==0){
        		k--;
        		if(k<1){
        			break;
        		}
        	}
        	x--;
        }
        System.out.println(x);
    }
} Main public static void main(String[] args){
        solve();
    } main {
        solve();
    } solve() solve String[] args args public static void solve(){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        int x = (int)Math.min(a, b);
        while(true){
        	if(a%x==0 && b%x==0){
        		k--;
        		if(k<1){
        			break;
        		}
        	}
        	x--;
        }
        System.out.println(x);
    } solve {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        int x = (int)Math.min(a, b);
        while(true){
        	if(a%x==0 && b%x==0){
        		k--;
        		if(k<1){
        			break;
        		}
        	}
        	x--;
        }
        System.out.println(x);
    } 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 int x = (int)Math.min(a, b); x (int)Math.min(a, b) Math.min Math a b while(true){
        	if(a%x==0 && b%x==0){
        		k--;
        		if(k<1){
        			break;
        		}
        	}
        	x--;
        } true {
        	if(a%x==0 && b%x==0){
        		k--;
        		if(k<1){
        			break;
        		}
        	}
        	x--;
        } if(a%x==0 && b%x==0){
        		k--;
        		if(k<1){
        			break;
        		}
        	} a%x==0 && b%x==0 a%x==0 a%x a x 0 b%x==0 b%x b x 0 {
        		k--;
        		if(k<1){
        			break;
        		}
        	} k-- k if(k<1){
        			break;
        		} k<1 k 1 {
        			break;
        		} break; x-- x System.out.println(x) System.out.println System.out System System.out x

import java.io.*;
import java.util.*;

class Main{
    public static void main(String[] args){
        solve();
    }

    public static void solve(){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int k = sc.nextInt();
        int x = (int)Math.min(a, b);
        while(true){
        	if(a%x==0 && b%x==0){
        		k--;
        		if(k<1){
        			break;
        		}
        	}
        	x--;
        }
        System.out.println(x);
    }
}