import java.io.*;
import java.util.*;
import java.lang.*;
import java.text.*;
import java.math.*;
public class Main {
	public static int gcd(int a,int b) {
		while(true) {
			a%=b;
			if(a==0)return b;
			b%=a;
			if(b==0)return a;
		}
	}
	public static void main(String[] args) throws IOException{
		BufferedReader re=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer t=new StringTokenizer(re.readLine());
		int a=Integer.parseInt(t.nextToken()),b=Integer.parseInt(t.nextToken()),k=Integer.parseInt(t.nextToken());
		int c=gcd(a,b),d=c;
		while(k>1) {
			if(c%--d==0)--k;
		}
		System.out.println(d);
	}
} import java.io.*; io.* java import java.util.*; util.* java import java.lang.*; lang.* java import java.text.*; text.* java import java.math.*; math.* java public class Main {
	public static int gcd(int a,int b) {
		while(true) {
			a%=b;
			if(a==0)return b;
			b%=a;
			if(b==0)return a;
		}
	}
	public static void main(String[] args) throws IOException{
		BufferedReader re=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer t=new StringTokenizer(re.readLine());
		int a=Integer.parseInt(t.nextToken()),b=Integer.parseInt(t.nextToken()),k=Integer.parseInt(t.nextToken());
		int c=gcd(a,b),d=c;
		while(k>1) {
			if(c%--d==0)--k;
		}
		System.out.println(d);
	}
} Main public static int gcd(int a,int b) {
		while(true) {
			a%=b;
			if(a==0)return b;
			b%=a;
			if(b==0)return a;
		}
	} gcd {
		while(true) {
			a%=b;
			if(a==0)return b;
			b%=a;
			if(b==0)return a;
		}
	} while(true) {
			a%=b;
			if(a==0)return b;
			b%=a;
			if(b==0)return a;
		} true {
			a%=b;
			if(a==0)return b;
			b%=a;
			if(b==0)return a;
		} a%=b a b if(a==0)return b; a==0 a 0 return b; b b%=a b a if(b==0)return a; b==0 b 0 return a; a int a a int b b public static void main(String[] args) throws IOException{
		BufferedReader re=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer t=new StringTokenizer(re.readLine());
		int a=Integer.parseInt(t.nextToken()),b=Integer.parseInt(t.nextToken()),k=Integer.parseInt(t.nextToken());
		int c=gcd(a,b),d=c;
		while(k>1) {
			if(c%--d==0)--k;
		}
		System.out.println(d);
	} main {
		BufferedReader re=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer t=new StringTokenizer(re.readLine());
		int a=Integer.parseInt(t.nextToken()),b=Integer.parseInt(t.nextToken()),k=Integer.parseInt(t.nextToken());
		int c=gcd(a,b),d=c;
		while(k>1) {
			if(c%--d==0)--k;
		}
		System.out.println(d);
	} BufferedReader re=new BufferedReader(new InputStreamReader(System.in)); re new BufferedReader(new InputStreamReader(System.in)) StringTokenizer t=new StringTokenizer(re.readLine()); t new StringTokenizer(re.readLine()) int a=Integer.parseInt(t.nextToken()) a Integer.parseInt(t.nextToken()) Integer.parseInt Integer t.nextToken() t.nextToken t b=Integer.parseInt(t.nextToken()) b Integer.parseInt(t.nextToken()) Integer.parseInt Integer t.nextToken() t.nextToken t k=Integer.parseInt(t.nextToken()); k Integer.parseInt(t.nextToken()) Integer.parseInt Integer t.nextToken() t.nextToken t int c=gcd(a,b) c gcd(a,b) gcd a b d=c; d c while(k>1) {
			if(c%--d==0)--k;
		} k>1 k 1 {
			if(c%--d==0)--k;
		} if(c%--d==0)--k; c%--d==0 c%--d c --d d 0 --k k System.out.println(d) System.out.println System.out System System.out d String[] args args public class Main {
	public static int gcd(int a,int b) {
		while(true) {
			a%=b;
			if(a==0)return b;
			b%=a;
			if(b==0)return a;
		}
	}
	public static void main(String[] args) throws IOException{
		BufferedReader re=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer t=new StringTokenizer(re.readLine());
		int a=Integer.parseInt(t.nextToken()),b=Integer.parseInt(t.nextToken()),k=Integer.parseInt(t.nextToken());
		int c=gcd(a,b),d=c;
		while(k>1) {
			if(c%--d==0)--k;
		}
		System.out.println(d);
	}
} public class Main {
	public static int gcd(int a,int b) {
		while(true) {
			a%=b;
			if(a==0)return b;
			b%=a;
			if(b==0)return a;
		}
	}
	public static void main(String[] args) throws IOException{
		BufferedReader re=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer t=new StringTokenizer(re.readLine());
		int a=Integer.parseInt(t.nextToken()),b=Integer.parseInt(t.nextToken()),k=Integer.parseInt(t.nextToken());
		int c=gcd(a,b),d=c;
		while(k>1) {
			if(c%--d==0)--k;
		}
		System.out.println(d);
	}
} Main
import java.io.*;
import java.util.*;
import java.lang.*;
import java.text.*;
import java.math.*;
public class Main {
	public static int gcd(int a,int b) {
		while(true) {
			a%=b;
			if(a==0)return b;
			b%=a;
			if(b==0)return a;
		}
	}
	public static void main(String[] args) throws IOException{
		BufferedReader re=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer t=new StringTokenizer(re.readLine());
		int a=Integer.parseInt(t.nextToken()),b=Integer.parseInt(t.nextToken()),k=Integer.parseInt(t.nextToken());
		int c=gcd(a,b),d=c;
		while(k>1) {
			if(c%--d==0)--k;
		}
		System.out.println(d);
	}
}
