/*package whatever //do not write package name here */

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

public class Main {
	public static void main (String[] args) {
		Scanner input = new Scanner(System.in);
		int a = input.nextInt();
		int b = input.nextInt();
		int k = input.nextInt();
		
		ArrayList<Integer> list = new ArrayList<>();
		ArrayList<Integer> lists = new ArrayList<>();
		
		for(int i=1;i<=a;i++)
		    if(a%i==0)
		        list.add(i);
		        
		for(int i=1;i<=b;i++)
		    if(b%i==0)
		        lists.add(i);
		        
		ArrayList<Integer> List = new ArrayList<>();
		
		for(int t:list)
		{
		    if(lists.contains(t))
		        List.add(t);
		}
		Collections.sort(List,Collections.reverseOrder());
		
		//System.out.println(List);
		System.out.println(List.get(k-1));
		
	}
} import java.io.*; io.* java import java.util.*; util.* java public class Main {
	public static void main (String[] args) {
		Scanner input = new Scanner(System.in);
		int a = input.nextInt();
		int b = input.nextInt();
		int k = input.nextInt();
		
		ArrayList<Integer> list = new ArrayList<>();
		ArrayList<Integer> lists = new ArrayList<>();
		
		for(int i=1;i<=a;i++)
		    if(a%i==0)
		        list.add(i);
		        
		for(int i=1;i<=b;i++)
		    if(b%i==0)
		        lists.add(i);
		        
		ArrayList<Integer> List = new ArrayList<>();
		
		for(int t:list)
		{
		    if(lists.contains(t))
		        List.add(t);
		}
		Collections.sort(List,Collections.reverseOrder());
		
		//System.out.println(List);
		System.out.println(List.get(k-1));
		
	}
} Main public static void main (String[] args) {
		Scanner input = new Scanner(System.in);
		int a = input.nextInt();
		int b = input.nextInt();
		int k = input.nextInt();
		
		ArrayList<Integer> list = new ArrayList<>();
		ArrayList<Integer> lists = new ArrayList<>();
		
		for(int i=1;i<=a;i++)
		    if(a%i==0)
		        list.add(i);
		        
		for(int i=1;i<=b;i++)
		    if(b%i==0)
		        lists.add(i);
		        
		ArrayList<Integer> List = new ArrayList<>();
		
		for(int t:list)
		{
		    if(lists.contains(t))
		        List.add(t);
		}
		Collections.sort(List,Collections.reverseOrder());
		
		//System.out.println(List);
		System.out.println(List.get(k-1));
		
	} main {
		Scanner input = new Scanner(System.in);
		int a = input.nextInt();
		int b = input.nextInt();
		int k = input.nextInt();
		
		ArrayList<Integer> list = new ArrayList<>();
		ArrayList<Integer> lists = new ArrayList<>();
		
		for(int i=1;i<=a;i++)
		    if(a%i==0)
		        list.add(i);
		        
		for(int i=1;i<=b;i++)
		    if(b%i==0)
		        lists.add(i);
		        
		ArrayList<Integer> List = new ArrayList<>();
		
		for(int t:list)
		{
		    if(lists.contains(t))
		        List.add(t);
		}
		Collections.sort(List,Collections.reverseOrder());
		
		//System.out.println(List);
		System.out.println(List.get(k-1));
		
	} Scanner input = new Scanner(System.in); input new Scanner(System.in) int a = input.nextInt(); a input.nextInt() input.nextInt input int b = input.nextInt(); b input.nextInt() input.nextInt input int k = input.nextInt(); k input.nextInt() input.nextInt input ArrayList<Integer> list = new ArrayList<>(); list new ArrayList<>() ArrayList<Integer> lists = new ArrayList<>(); lists new ArrayList<>() for(int i=1;i<=a;i++)
		    if(a%i==0)
		        list.add(i); int i=1; int i=1; i 1 i<=a i a i++ i++ i if(a%i==0)
		        list.add(i); if(a%i==0)
		        list.add(i); a%i==0 a%i a i 0 list.add(i) list.add list i for(int i=1;i<=b;i++)
		    if(b%i==0)
		        lists.add(i); int i=1; int i=1; i 1 i<=b i b i++ i++ i if(b%i==0)
		        lists.add(i); if(b%i==0)
		        lists.add(i); b%i==0 b%i b i 0 lists.add(i) lists.add lists i ArrayList<Integer> List = new ArrayList<>(); List new ArrayList<>() for(int t:list)
		{
		    if(lists.contains(t))
		        List.add(t);
		} int t list {
		    if(lists.contains(t))
		        List.add(t);
		} {
		    if(lists.contains(t))
		        List.add(t);
		} if(lists.contains(t))
		        List.add(t); lists.contains(t) lists.contains lists t List.add(t) List.add List t Collections.sort(List,Collections.reverseOrder()) Collections.sort Collections List Collections.reverseOrder() Collections.reverseOrder Collections System.out.println(List.get(k-1)) System.out.println System.out System System.out List.get(k-1) List.get List k-1 k 1 String[] args args public class Main {
	public static void main (String[] args) {
		Scanner input = new Scanner(System.in);
		int a = input.nextInt();
		int b = input.nextInt();
		int k = input.nextInt();
		
		ArrayList<Integer> list = new ArrayList<>();
		ArrayList<Integer> lists = new ArrayList<>();
		
		for(int i=1;i<=a;i++)
		    if(a%i==0)
		        list.add(i);
		        
		for(int i=1;i<=b;i++)
		    if(b%i==0)
		        lists.add(i);
		        
		ArrayList<Integer> List = new ArrayList<>();
		
		for(int t:list)
		{
		    if(lists.contains(t))
		        List.add(t);
		}
		Collections.sort(List,Collections.reverseOrder());
		
		//System.out.println(List);
		System.out.println(List.get(k-1));
		
	}
} public class Main {
	public static void main (String[] args) {
		Scanner input = new Scanner(System.in);
		int a = input.nextInt();
		int b = input.nextInt();
		int k = input.nextInt();
		
		ArrayList<Integer> list = new ArrayList<>();
		ArrayList<Integer> lists = new ArrayList<>();
		
		for(int i=1;i<=a;i++)
		    if(a%i==0)
		        list.add(i);
		        
		for(int i=1;i<=b;i++)
		    if(b%i==0)
		        lists.add(i);
		        
		ArrayList<Integer> List = new ArrayList<>();
		
		for(int t:list)
		{
		    if(lists.contains(t))
		        List.add(t);
		}
		Collections.sort(List,Collections.reverseOrder());
		
		//System.out.println(List);
		System.out.println(List.get(k-1));
		
	}
} Main
/*package whatever //do not write package name here */

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

public class Main {
	public static void main (String[] args) {
		Scanner input = new Scanner(System.in);
		int a = input.nextInt();
		int b = input.nextInt();
		int k = input.nextInt();
		
		ArrayList<Integer> list = new ArrayList<>();
		ArrayList<Integer> lists = new ArrayList<>();
		
		for(int i=1;i<=a;i++)
		    if(a%i==0)
		        list.add(i);
		        
		for(int i=1;i<=b;i++)
		    if(b%i==0)
		        lists.add(i);
		        
		ArrayList<Integer> List = new ArrayList<>();
		
		for(int t:list)
		{
		    if(lists.contains(t))
		        List.add(t);
		}
		Collections.sort(List,Collections.reverseOrder());
		
		//System.out.println(List);
		System.out.println(List.get(k-1));
		
	}
}