import java.util.*;
import java.util.Scanner;

public class Main {
    public static void main (String args[]) {
        // input

        int a;
        int b;

        Scanner inp = new Scanner(System.in);

        a = inp.nextInt();

        b = inp.nextInt();

       while (b != 0) {
           int temp = a;
           a = b;
           b = temp%b;
       }

       System.out.println(a);
    }
} import java.util.*; util.* java import java.util.Scanner; Scanner java.util public class Main {
    public static void main (String args[]) {
        // input

        int a;
        int b;

        Scanner inp = new Scanner(System.in);

        a = inp.nextInt();

        b = inp.nextInt();

       while (b != 0) {
           int temp = a;
           a = b;
           b = temp%b;
       }

       System.out.println(a);
    }
} Main public static void main (String args[]) {
        // input

        int a;
        int b;

        Scanner inp = new Scanner(System.in);

        a = inp.nextInt();

        b = inp.nextInt();

       while (b != 0) {
           int temp = a;
           a = b;
           b = temp%b;
       }

       System.out.println(a);
    } main {
        // input

        int a;
        int b;

        Scanner inp = new Scanner(System.in);

        a = inp.nextInt();

        b = inp.nextInt();

       while (b != 0) {
           int temp = a;
           a = b;
           b = temp%b;
       }

       System.out.println(a);
    } int a; a int b; b Scanner inp = new Scanner(System.in); inp new Scanner(System.in) a = inp.nextInt() a inp.nextInt() inp.nextInt inp b = inp.nextInt() b inp.nextInt() inp.nextInt inp while (b != 0) {
           int temp = a;
           a = b;
           b = temp%b;
       } b != 0 b 0 {
           int temp = a;
           a = b;
           b = temp%b;
       } int temp = a; temp a a = b a b b = temp%b b temp%b temp b System.out.println(a) System.out.println System.out System System.out a String args[] args public class Main {
    public static void main (String args[]) {
        // input

        int a;
        int b;

        Scanner inp = new Scanner(System.in);

        a = inp.nextInt();

        b = inp.nextInt();

       while (b != 0) {
           int temp = a;
           a = b;
           b = temp%b;
       }

       System.out.println(a);
    }
} public class Main {
    public static void main (String args[]) {
        // input

        int a;
        int b;

        Scanner inp = new Scanner(System.in);

        a = inp.nextInt();

        b = inp.nextInt();

       while (b != 0) {
           int temp = a;
           a = b;
           b = temp%b;
       }

       System.out.println(a);
    }
} Main
import java.util.*;
import java.util.Scanner;

public class Main {
    public static void main (String args[]) {
        // input

        int a;
        int b;

        Scanner inp = new Scanner(System.in);

        a = inp.nextInt();

        b = inp.nextInt();

       while (b != 0) {
           int temp = a;
           a = b;
           b = temp%b;
       }

       System.out.println(a);
    }
}
