using System;
class Solution {
    static void Main(String[] args) {
        var numbers = Console.ReadLine().Split(' ');
        var x = int.Parse(numbers[0]);
        var y = int.Parse(numbers[1]);
        
        Console.WriteLine(gcd(x, y));
    }
    static int gcd(int x, int y){
        if(x % y == 0){
            return y;
        }
        else {
            var min = Math.Min(x, y);
            var max = Math.Max(x, y);
            return gcd(max%min, min);
        }
    }
}