import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val x = sc.nextInt()
    val y = sc.nextInt()

    def gcb(a: Int, b: Int): Int = {
      if (b == 0) a else gcb(b, a % b)
    }

    println(gcb(Math.max(x, y), Math.min(x, y)))
  }

}


