import java.util.*

fun gcd(x: Int, y: Int): Int {
    if (x < y) {
        return gcd(y, x)
    }
    if (y == 0) {
        return x
    }
    return gcd(y, x % y)
}

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val x = scanner.nextInt()
    val y = scanner.nextInt()

    println(gcd(x, y))
}

