fun gcd(a: Int, b: Int): Int =
        when (b) {
            0 -> a
            else -> gcd(b, a % b)
        }

fun main(args: Array<String>) {
    readLine()
            ?.split(regex = """\s+""".toRegex())
            ?.map { it.toInt() }
            ?.toIntArray()
            ?.let { println(gcd(it[0], it[1])) }
}
