import scala.io.StdIn.readLine

object Main extends App {
  def gcd(x:Int,y:Int):Int = if(y>0) { if(x>=y) gcd(y,x%y) else gcd(x,y%x) } else x

  val Array(x,y) = readLine.split(" ").map(_.toInt)
  println(gcd(x,y))
}