object Main {
  def main(args: Array[String]): Unit = {
    val Array(x, y, _*) = io.StdIn.readLine().split(" ").map(_.toInt)
    println(gcd(x, y))
  }

  @annotation.tailrec
  def gcd(x: Int, y: Int): Int = {
    if (y == 0)
      x
    else
      gcd(y, x % y)
  }
}