package com.codegym.task.task14.task1420;
import java.io.*;
/*
GCD

*/

public class Solution {
    public static void main(String[] args) throws Exception {
         BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

            int a = Integer.parseInt(reader.readLine());
            int b = Integer.parseInt(reader.readLine());
            System.out.println(gcd(a,b));

    }

    public static int gcd(int x, int y) {
        int gcd = 1;
        for(int i = 1; i <= x && i <= y; i++)
        {
            if(x % i == 0 && y % i == 0)
                gcd = i;
        }
        return gcd;
    }

}