import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long y = sc.nextLong();
        long z = 1;
        for(int i = 1; i <= x; i++){
            if(x%i == 0){
                z = x/i;
                if(y%z == 0){
                    break;
                }
            }
        }
        System.out.println(z);
    }  
} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long y = sc.nextLong();
        long z = 1;
        for(int i = 1; i <= x; i++){
            if(x%i == 0){
                z = x/i;
                if(y%z == 0){
                    break;
                }
            }
        }
        System.out.println(z);
    }  
} Main public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long y = sc.nextLong();
        long z = 1;
        for(int i = 1; i <= x; i++){
            if(x%i == 0){
                z = x/i;
                if(y%z == 0){
                    break;
                }
            }
        }
        System.out.println(z);
    } main {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long y = sc.nextLong();
        long z = 1;
        for(int i = 1; i <= x; i++){
            if(x%i == 0){
                z = x/i;
                if(y%z == 0){
                    break;
                }
            }
        }
        System.out.println(z);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) long x = sc.nextLong(); x sc.nextLong() sc.nextLong sc long y = sc.nextLong(); y sc.nextLong() sc.nextLong sc long z = 1; z 1 for(int i = 1; i <= x; i++){
            if(x%i == 0){
                z = x/i;
                if(y%z == 0){
                    break;
                }
            }
        } int i = 1; int i = 1; i 1 i <= x i x i++ i++ i {
            if(x%i == 0){
                z = x/i;
                if(y%z == 0){
                    break;
                }
            }
        } {
            if(x%i == 0){
                z = x/i;
                if(y%z == 0){
                    break;
                }
            }
        } if(x%i == 0){
                z = x/i;
                if(y%z == 0){
                    break;
                }
            } x%i == 0 x%i x i 0 {
                z = x/i;
                if(y%z == 0){
                    break;
                }
            } z = x/i z x/i x i if(y%z == 0){
                    break;
                } y%z == 0 y%z y z 0 {
                    break;
                } break; System.out.println(z) System.out.println System.out System System.out z String[] args args public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long y = sc.nextLong();
        long z = 1;
        for(int i = 1; i <= x; i++){
            if(x%i == 0){
                z = x/i;
                if(y%z == 0){
                    break;
                }
            }
        }
        System.out.println(z);
    }  
} public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long y = sc.nextLong();
        long z = 1;
        for(int i = 1; i <= x; i++){
            if(x%i == 0){
                z = x/i;
                if(y%z == 0){
                    break;
                }
            }
        }
        System.out.println(z);
    }  
} Main
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long y = sc.nextLong();
        long z = 1;
        for(int i = 1; i <= x; i++){
            if(x%i == 0){
                z = x/i;
                if(y%z == 0){
                    break;
                }
            }
        }
        System.out.println(z);
    }  
}
