MODE = "stdiro"
#require 'matrix'
#include Math
line = Array.new

if(defined? MODE)
  line = STDIN.read.split("\n")
else
  tmp = '147 105'.split("\n")
  tmp.each{|s|
    line << s.strip
  }
end
def gcd(x,y)
  x,y=[x,y].sort
  while y>0
    r=x%y
    x=y
    y=r
  end
  return x
end
  
x,y = line[0].split(" ").map(&:to_i)

puts gcd(x,y)