import java.util.Scanner

object Main {
  def main(args: Array[String]) {
    def gcd(a: Int, b: Int): Int = {
      return b match {
        case 0 => a
        case x => gcd(x, a % x)
      }
    }
    val in = new Scanner(System.in)
    val ans = gcd(in.nextInt(), in.nextInt())
    println(ans)
  }
}