import scala.io.StdIn
 
object Main{
  def main(args: Array[String]) = {
    def gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b)
    val (a :: b :: _) = StdIn.readLine().split(" ").map(_.toInt)
    println(gcd(a, b))
  }
}
 