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)
  n= [x, y].min
  n.downto(1) do |d|
    if(x%d==0)&&(y%d==0)
      return d
    end
  end
end
  
x,y = line[0].split(" ").map(&:to_i)

p gcd(x,y)