const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const lines = input.split("\n");

const n = lines[0].split(" ").map(Number)

let nmax = Math.max.apply(null,n);
let nmin = Math.min.apply(null,n);

while(nmax%nmin !== 0){
    let t = nmax%nmin
    nmax = nmin
    nmin = t
}
console.log(nmin)
