import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    	Scanner in = new Scanner(System.in);
    	int a,b,k;
    	
    	a = in.nextInt();
    	b = in.nextInt();
    	k = in.nextInt();
    	
//    	int div = Math.abs(a-b);
//    	if (div == 0) {
//    		div = a;
//    	}
    	int counter = 0;
    	
    	for (int i = a; i > 0; i--) {
    		if (a % i == 0 && b % i == 0) {
    			counter++;
    			if (counter == k) {
    				System.out.println(i);
    				return;
    			}
    		}
    	}
    	
    }

  } import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
    	Scanner in = new Scanner(System.in);
    	int a,b,k;
    	
    	a = in.nextInt();
    	b = in.nextInt();
    	k = in.nextInt();
    	
//    	int div = Math.abs(a-b);
//    	if (div == 0) {
//    		div = a;
//    	}
    	int counter = 0;
    	
    	for (int i = a; i > 0; i--) {
    		if (a % i == 0 && b % i == 0) {
    			counter++;
    			if (counter == k) {
    				System.out.println(i);
    				return;
    			}
    		}
    	}
    	
    }

  } Main public static void main(String[] args) {
    	Scanner in = new Scanner(System.in);
    	int a,b,k;
    	
    	a = in.nextInt();
    	b = in.nextInt();
    	k = in.nextInt();
    	
//    	int div = Math.abs(a-b);
//    	if (div == 0) {
//    		div = a;
//    	}
    	int counter = 0;
    	
    	for (int i = a; i > 0; i--) {
    		if (a % i == 0 && b % i == 0) {
    			counter++;
    			if (counter == k) {
    				System.out.println(i);
    				return;
    			}
    		}
    	}
    	
    } main {
    	Scanner in = new Scanner(System.in);
    	int a,b,k;
    	
    	a = in.nextInt();
    	b = in.nextInt();
    	k = in.nextInt();
    	
//    	int div = Math.abs(a-b);
//    	if (div == 0) {
//    		div = a;
//    	}
    	int counter = 0;
    	
    	for (int i = a; i > 0; i--) {
    		if (a % i == 0 && b % i == 0) {
    			counter++;
    			if (counter == k) {
    				System.out.println(i);
    				return;
    			}
    		}
    	}
    	
    } Scanner in = new Scanner(System.in); in new Scanner(System.in) int a a b b k; k a = in.nextInt() a in.nextInt() in.nextInt in b = in.nextInt() b in.nextInt() in.nextInt in k = in.nextInt() k in.nextInt() in.nextInt in int counter = 0; counter 0 for (int i = a; i > 0; i--) {
    		if (a % i == 0 && b % i == 0) {
    			counter++;
    			if (counter == k) {
    				System.out.println(i);
    				return;
    			}
    		}
    	} int i = a; int i = a; i a i > 0 i 0 i-- i-- i {
    		if (a % i == 0 && b % i == 0) {
    			counter++;
    			if (counter == k) {
    				System.out.println(i);
    				return;
    			}
    		}
    	} {
    		if (a % i == 0 && b % i == 0) {
    			counter++;
    			if (counter == k) {
    				System.out.println(i);
    				return;
    			}
    		}
    	} if (a % i == 0 && b % i == 0) {
    			counter++;
    			if (counter == k) {
    				System.out.println(i);
    				return;
    			}
    		} a % i == 0 && b % i == 0 a % i == 0 a % i a i 0 b % i == 0 b % i b i 0 {
    			counter++;
    			if (counter == k) {
    				System.out.println(i);
    				return;
    			}
    		} counter++ counter if (counter == k) {
    				System.out.println(i);
    				return;
    			} counter == k counter k {
    				System.out.println(i);
    				return;
    			} System.out.println(i) System.out.println System.out System System.out i return; String[] args args public class Main {
    public static void main(String[] args) {
    	Scanner in = new Scanner(System.in);
    	int a,b,k;
    	
    	a = in.nextInt();
    	b = in.nextInt();
    	k = in.nextInt();
    	
//    	int div = Math.abs(a-b);
//    	if (div == 0) {
//    		div = a;
//    	}
    	int counter = 0;
    	
    	for (int i = a; i > 0; i--) {
    		if (a % i == 0 && b % i == 0) {
    			counter++;
    			if (counter == k) {
    				System.out.println(i);
    				return;
    			}
    		}
    	}
    	
    }

  } public class Main {
    public static void main(String[] args) {
    	Scanner in = new Scanner(System.in);
    	int a,b,k;
    	
    	a = in.nextInt();
    	b = in.nextInt();
    	k = in.nextInt();
    	
//    	int div = Math.abs(a-b);
//    	if (div == 0) {
//    		div = a;
//    	}
    	int counter = 0;
    	
    	for (int i = a; i > 0; i--) {
    		if (a % i == 0 && b % i == 0) {
    			counter++;
    			if (counter == k) {
    				System.out.println(i);
    				return;
    			}
    		}
    	}
    	
    }

  } Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    	Scanner in = new Scanner(System.in);
    	int a,b,k;
    	
    	a = in.nextInt();
    	b = in.nextInt();
    	k = in.nextInt();
    	
//    	int div = Math.abs(a-b);
//    	if (div == 0) {
//    		div = a;
//    	}
    	int counter = 0;
    	
    	for (int i = a; i > 0; i--) {
    		if (a % i == 0 && b % i == 0) {
    			counter++;
    			if (counter == k) {
    				System.out.println(i);
    				return;
    			}
    		}
    	}
    	
    }

  }
