import java.io.*;

class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] input = br.readLine().split(" ");
        int a = Integer.parseInt(input[0]);
        int b = Integer.parseInt(input[1]);
        int gcd = 1;
        if (a > b) {
            int temp = b;
            b = a;
            a = temp;
        }
        int i = 2;
        while (i <= a) {
            if (a%i == 0 && b%i == 0) {
                gcd *= i;
                a /= i;
                b /= i;
            } else i++;
        }

        System.out.println(gcd);
    }
} import java.io.*; io.* java class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] input = br.readLine().split(" ");
        int a = Integer.parseInt(input[0]);
        int b = Integer.parseInt(input[1]);
        int gcd = 1;
        if (a > b) {
            int temp = b;
            b = a;
            a = temp;
        }
        int i = 2;
        while (i <= a) {
            if (a%i == 0 && b%i == 0) {
                gcd *= i;
                a /= i;
                b /= i;
            } else i++;
        }

        System.out.println(gcd);
    }
} Main public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] input = br.readLine().split(" ");
        int a = Integer.parseInt(input[0]);
        int b = Integer.parseInt(input[1]);
        int gcd = 1;
        if (a > b) {
            int temp = b;
            b = a;
            a = temp;
        }
        int i = 2;
        while (i <= a) {
            if (a%i == 0 && b%i == 0) {
                gcd *= i;
                a /= i;
                b /= i;
            } else i++;
        }

        System.out.println(gcd);
    } main {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] input = br.readLine().split(" ");
        int a = Integer.parseInt(input[0]);
        int b = Integer.parseInt(input[1]);
        int gcd = 1;
        if (a > b) {
            int temp = b;
            b = a;
            a = temp;
        }
        int i = 2;
        while (i <= a) {
            if (a%i == 0 && b%i == 0) {
                gcd *= i;
                a /= i;
                b /= i;
            } else i++;
        }

        System.out.println(gcd);
    } BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); br new BufferedReader(new InputStreamReader(System.in)) String[] input = br.readLine().split(" "); input br.readLine().split(" ") br.readLine().split br.readLine() br.readLine br " " int a = Integer.parseInt(input[0]); a Integer.parseInt(input[0]) Integer.parseInt Integer input[0] input 0 int b = Integer.parseInt(input[1]); b Integer.parseInt(input[1]) Integer.parseInt Integer input[1] input 1 int gcd = 1; gcd 1 if (a > b) {
            int temp = b;
            b = a;
            a = temp;
        } a > b a b {
            int temp = b;
            b = a;
            a = temp;
        } int temp = b; temp b b = a b a a = temp a temp int i = 2; i 2 while (i <= a) {
            if (a%i == 0 && b%i == 0) {
                gcd *= i;
                a /= i;
                b /= i;
            } else i++;
        } i <= a i a {
            if (a%i == 0 && b%i == 0) {
                gcd *= i;
                a /= i;
                b /= i;
            } else i++;
        } if (a%i == 0 && b%i == 0) {
                gcd *= i;
                a /= i;
                b /= i;
            } else i++; a%i == 0 && b%i == 0 a%i == 0 a%i a i 0 b%i == 0 b%i b i 0 {
                gcd *= i;
                a /= i;
                b /= i;
            } gcd *= i gcd i a /= i a i b /= i b i i++ i System.out.println(gcd) System.out.println System.out System System.out gcd String[] args args
import java.io.*;

class Main {
    public static void main (String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] input = br.readLine().split(" ");
        int a = Integer.parseInt(input[0]);
        int b = Integer.parseInt(input[1]);
        int gcd = 1;
        if (a > b) {
            int temp = b;
            b = a;
            a = temp;
        }
        int i = 2;
        while (i <= a) {
            if (a%i == 0 && b%i == 0) {
                gcd *= i;
                a /= i;
                b /= i;
            } else i++;
        }

        System.out.println(gcd);
    }
}