import java.math.BigInteger

/**
 * Created by m00nlight on 7/27/15.
 */
object Main {
  def main(args: Array[String]) {
    val xs = io.Source.stdin.getLines().toList.head.split("\\s+").map(_.toInt)
    val a = new BigInt(BigInteger.valueOf(xs.head))
    val b = new BigInt(BigInteger.valueOf(xs.tail.head))
    println(a.gcd(b))
  }
}