function main(_stdin) {
    const stdin = _stdin.split(' ').map(Number);
    let max = Math.max.apply(null, stdin);
    let min = Math.min.apply(null, stdin);

    while (min !== 0) {
        let _min = min;
        min = max % min;
        max = _min;
    }
    console.log(max);
}


main(require('fs').readFileSync('/dev/stdin', 'utf8'));

