import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = Integer.valueOf(scan.next());
        int b = Integer.valueOf(scan.next());
        int r = 0;
        while (b != 0) {
            r = a % b;
            a = b;
            b = r;
        }
        System.out.println(a);
        scan.close();
    }
} import java.util.Scanner; Scanner java.util public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = Integer.valueOf(scan.next());
        int b = Integer.valueOf(scan.next());
        int r = 0;
        while (b != 0) {
            r = a % b;
            a = b;
            b = r;
        }
        System.out.println(a);
        scan.close();
    }
} Main public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = Integer.valueOf(scan.next());
        int b = Integer.valueOf(scan.next());
        int r = 0;
        while (b != 0) {
            r = a % b;
            a = b;
            b = r;
        }
        System.out.println(a);
        scan.close();
    } main {
        Scanner scan = new Scanner(System.in);
        int a = Integer.valueOf(scan.next());
        int b = Integer.valueOf(scan.next());
        int r = 0;
        while (b != 0) {
            r = a % b;
            a = b;
            b = r;
        }
        System.out.println(a);
        scan.close();
    } Scanner scan = new Scanner(System.in); scan new Scanner(System.in) int a = Integer.valueOf(scan.next()); a Integer.valueOf(scan.next()) Integer.valueOf Integer scan.next() scan.next scan int b = Integer.valueOf(scan.next()); b Integer.valueOf(scan.next()) Integer.valueOf Integer scan.next() scan.next scan int r = 0; r 0 while (b != 0) {
            r = a % b;
            a = b;
            b = r;
        } b != 0 b 0 {
            r = a % b;
            a = b;
            b = r;
        } r = a % b r a % b a b a = b a b b = r b r System.out.println(a) System.out.println System.out System System.out a scan.close() scan.close scan String[] args args public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = Integer.valueOf(scan.next());
        int b = Integer.valueOf(scan.next());
        int r = 0;
        while (b != 0) {
            r = a % b;
            a = b;
            b = r;
        }
        System.out.println(a);
        scan.close();
    }
} public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = Integer.valueOf(scan.next());
        int b = Integer.valueOf(scan.next());
        int r = 0;
        while (b != 0) {
            r = a % b;
            a = b;
            b = r;
        }
        System.out.println(a);
        scan.close();
    }
} Main
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int a = Integer.valueOf(scan.next());
        int b = Integer.valueOf(scan.next());
        int r = 0;
        while (b != 0) {
            r = a % b;
            a = b;
            b = r;
        }
        System.out.println(a);
        scan.close();
    }
}
