import java.util.*;

public class Main{
  
  public static void main (String[] args){
    
    Main main = new Main();
    main.solve();
  }
  
  private void solve(){
    
	Scanner scanner = new Scanner (System.in);
    
    int A = scanner.nextInt();
    int B = scanner.nextInt();
    int K = scanner.nextInt();
    
    int count = 0;
    
    int number;
    
    if (A<B){
      number=A;
    }else {
      number=B;
    }
    
    for (; number<=A&&number<=B; number--){
      
      if(A%number==0&&B%number==0){
        count++;
        if (count==K){
          System.out.println(number);
          break;
        }
      }
    }
  }
} import java.util.*; util.* java public class Main{
  
  public static void main (String[] args){
    
    Main main = new Main();
    main.solve();
  }
  
  private void solve(){
    
	Scanner scanner = new Scanner (System.in);
    
    int A = scanner.nextInt();
    int B = scanner.nextInt();
    int K = scanner.nextInt();
    
    int count = 0;
    
    int number;
    
    if (A<B){
      number=A;
    }else {
      number=B;
    }
    
    for (; number<=A&&number<=B; number--){
      
      if(A%number==0&&B%number==0){
        count++;
        if (count==K){
          System.out.println(number);
          break;
        }
      }
    }
  }
} Main public static void main (String[] args){
    
    Main main = new Main();
    main.solve();
  } main {
    
    Main main = new Main();
    main.solve();
  } Main main = new Main(); main new Main() main.solve() main.solve main String[] args args private void solve(){
    
	Scanner scanner = new Scanner (System.in);
    
    int A = scanner.nextInt();
    int B = scanner.nextInt();
    int K = scanner.nextInt();
    
    int count = 0;
    
    int number;
    
    if (A<B){
      number=A;
    }else {
      number=B;
    }
    
    for (; number<=A&&number<=B; number--){
      
      if(A%number==0&&B%number==0){
        count++;
        if (count==K){
          System.out.println(number);
          break;
        }
      }
    }
  } solve {
    
	Scanner scanner = new Scanner (System.in);
    
    int A = scanner.nextInt();
    int B = scanner.nextInt();
    int K = scanner.nextInt();
    
    int count = 0;
    
    int number;
    
    if (A<B){
      number=A;
    }else {
      number=B;
    }
    
    for (; number<=A&&number<=B; number--){
      
      if(A%number==0&&B%number==0){
        count++;
        if (count==K){
          System.out.println(number);
          break;
        }
      }
    }
  } Scanner scanner = new Scanner (System.in); scanner new Scanner (System.in) int A = scanner.nextInt(); A scanner.nextInt() scanner.nextInt scanner int B = scanner.nextInt(); B scanner.nextInt() scanner.nextInt scanner int K = scanner.nextInt(); K scanner.nextInt() scanner.nextInt scanner int count = 0; count 0 int number; number if (A<B){
      number=A;
    }else {
      number=B;
    } A<B A B {
      number=A;
    } number=A number A {
      number=B;
    } number=B number B for (; number<=A&&number<=B; number--){
      
      if(A%number==0&&B%number==0){
        count++;
        if (count==K){
          System.out.println(number);
          break;
        }
      }
    } ; number<=A&&number<=B number<=A number A number<=B number B number-- number-- number {
      
      if(A%number==0&&B%number==0){
        count++;
        if (count==K){
          System.out.println(number);
          break;
        }
      }
    } {
      
      if(A%number==0&&B%number==0){
        count++;
        if (count==K){
          System.out.println(number);
          break;
        }
      }
    } if(A%number==0&&B%number==0){
        count++;
        if (count==K){
          System.out.println(number);
          break;
        }
      } A%number==0&&B%number==0 A%number==0 A%number A number 0 B%number==0 B%number B number 0 {
        count++;
        if (count==K){
          System.out.println(number);
          break;
        }
      } count++ count if (count==K){
          System.out.println(number);
          break;
        } count==K count K {
          System.out.println(number);
          break;
        } System.out.println(number) System.out.println System.out System System.out number break; public class Main{
  
  public static void main (String[] args){
    
    Main main = new Main();
    main.solve();
  }
  
  private void solve(){
    
	Scanner scanner = new Scanner (System.in);
    
    int A = scanner.nextInt();
    int B = scanner.nextInt();
    int K = scanner.nextInt();
    
    int count = 0;
    
    int number;
    
    if (A<B){
      number=A;
    }else {
      number=B;
    }
    
    for (; number<=A&&number<=B; number--){
      
      if(A%number==0&&B%number==0){
        count++;
        if (count==K){
          System.out.println(number);
          break;
        }
      }
    }
  }
} public class Main{
  
  public static void main (String[] args){
    
    Main main = new Main();
    main.solve();
  }
  
  private void solve(){
    
	Scanner scanner = new Scanner (System.in);
    
    int A = scanner.nextInt();
    int B = scanner.nextInt();
    int K = scanner.nextInt();
    
    int count = 0;
    
    int number;
    
    if (A<B){
      number=A;
    }else {
      number=B;
    }
    
    for (; number<=A&&number<=B; number--){
      
      if(A%number==0&&B%number==0){
        count++;
        if (count==K){
          System.out.println(number);
          break;
        }
      }
    }
  }
} Main
import java.util.*;

public class Main{
  
  public static void main (String[] args){
    
    Main main = new Main();
    main.solve();
  }
  
  private void solve(){
    
	Scanner scanner = new Scanner (System.in);
    
    int A = scanner.nextInt();
    int B = scanner.nextInt();
    int K = scanner.nextInt();
    
    int count = 0;
    
    int number;
    
    if (A<B){
      number=A;
    }else {
      number=B;
    }
    
    for (; number<=A&&number<=B; number--){
      
      if(A%number==0&&B%number==0){
        count++;
        if (count==K){
          System.out.println(number);
          break;
        }
      }
    }
  }
}