
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Scanner;


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();
		int max = A>B ? A:B;
		ArrayList <Integer>Ablock = new ArrayList();
		
			int i = 0;
			int e = 0;
			int counter=0;
			for(i =1; i<=A;i++ ) {
				if(A%i ==0) {
					if(B%i ==0) {
						Ablock.add(i);
						
						}
						
					}
					
				}
			
			Ablock.sort(Comparator.reverseOrder());
			e = Ablock.get(K-1);
			
			
			System.out.println(e);
		
		
		
	}} import java.util.ArrayList; ArrayList java.util import java.util.Comparator; Comparator java.util import java.util.Scanner; Scanner java.util 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();
		int max = A>B ? A:B;
		ArrayList <Integer>Ablock = new ArrayList();
		
			int i = 0;
			int e = 0;
			int counter=0;
			for(i =1; i<=A;i++ ) {
				if(A%i ==0) {
					if(B%i ==0) {
						Ablock.add(i);
						
						}
						
					}
					
				}
			
			Ablock.sort(Comparator.reverseOrder());
			e = Ablock.get(K-1);
			
			
			System.out.println(e);
		
		
		
	}} 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();
		int max = A>B ? A:B;
		ArrayList <Integer>Ablock = new ArrayList();
		
			int i = 0;
			int e = 0;
			int counter=0;
			for(i =1; i<=A;i++ ) {
				if(A%i ==0) {
					if(B%i ==0) {
						Ablock.add(i);
						
						}
						
					}
					
				}
			
			Ablock.sort(Comparator.reverseOrder());
			e = Ablock.get(K-1);
			
			
			System.out.println(e);
		
		
		
	} main {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int K = sc.nextInt();
		int max = A>B ? A:B;
		ArrayList <Integer>Ablock = new ArrayList();
		
			int i = 0;
			int e = 0;
			int counter=0;
			for(i =1; i<=A;i++ ) {
				if(A%i ==0) {
					if(B%i ==0) {
						Ablock.add(i);
						
						}
						
					}
					
				}
			
			Ablock.sort(Comparator.reverseOrder());
			e = Ablock.get(K-1);
			
			
			System.out.println(e);
		
		
		
	} 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 max = A>B ? A:B; max A>B ? A:B A>B A B A B ArrayList <Integer>Ablock = new ArrayList(); Ablock new ArrayList() int i = 0; i 0 int e = 0; e 0 int counter=0; counter 0 for(i =1; i<=A;i++ ) {
				if(A%i ==0) {
					if(B%i ==0) {
						Ablock.add(i);
						
						}
						
					}
					
				} i =1; i =1 i 1 i<=A i A i++ i++ i {
				if(A%i ==0) {
					if(B%i ==0) {
						Ablock.add(i);
						
						}
						
					}
					
				} {
				if(A%i ==0) {
					if(B%i ==0) {
						Ablock.add(i);
						
						}
						
					}
					
				} if(A%i ==0) {
					if(B%i ==0) {
						Ablock.add(i);
						
						}
						
					} A%i ==0 A%i A i 0 {
					if(B%i ==0) {
						Ablock.add(i);
						
						}
						
					} if(B%i ==0) {
						Ablock.add(i);
						
						} B%i ==0 B%i B i 0 {
						Ablock.add(i);
						
						} Ablock.add(i) Ablock.add Ablock i Ablock.sort(Comparator.reverseOrder()) Ablock.sort Ablock Comparator.reverseOrder() Comparator.reverseOrder Comparator e = Ablock.get(K-1) e Ablock.get(K-1) Ablock.get Ablock K-1 K 1 System.out.println(e) System.out.println System.out System System.out e 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();
		int max = A>B ? A:B;
		ArrayList <Integer>Ablock = new ArrayList();
		
			int i = 0;
			int e = 0;
			int counter=0;
			for(i =1; i<=A;i++ ) {
				if(A%i ==0) {
					if(B%i ==0) {
						Ablock.add(i);
						
						}
						
					}
					
				}
			
			Ablock.sort(Comparator.reverseOrder());
			e = Ablock.get(K-1);
			
			
			System.out.println(e);
		
		
		
	}} 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();
		int max = A>B ? A:B;
		ArrayList <Integer>Ablock = new ArrayList();
		
			int i = 0;
			int e = 0;
			int counter=0;
			for(i =1; i<=A;i++ ) {
				if(A%i ==0) {
					if(B%i ==0) {
						Ablock.add(i);
						
						}
						
					}
					
				}
			
			Ablock.sort(Comparator.reverseOrder());
			e = Ablock.get(K-1);
			
			
			System.out.println(e);
		
		
		
	}} Main

import java.util.ArrayList;
import java.util.Comparator;
import java.util.Scanner;


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();
		int max = A>B ? A:B;
		ArrayList <Integer>Ablock = new ArrayList();
		
			int i = 0;
			int e = 0;
			int counter=0;
			for(i =1; i<=A;i++ ) {
				if(A%i ==0) {
					if(B%i ==0) {
						Ablock.add(i);
						
						}
						
					}
					
				}
			
			Ablock.sort(Comparator.reverseOrder());
			e = Ablock.get(K-1);
			
			
			System.out.println(e);
		
		
		
	}}