var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=input.split("\n");
var A=Arr[0].split(" ").map(Number);

gcd(A[0],A[1]);

function gcd(x,y){
    
    if(x>y){
        if((x % y) === 0){
            console.log(y);
        }else{
            gcd(y,x%y);
        }
    }else{
        if((y % x) === 0){
            console.log(x);
        }else{
            gcd(x,y%x);
        }
    }

}
