import sys

def gcd(x, y):
  if y == 1:
    return 1
  elif y == 0:
    return x
  else:
    return gcd(y, x % y)

line = sys.stdin.readline()
(a, b) = line.split()
a = int(a)
b = int(b)
if a > b:
  b, a = a, b

print gcd(a, b) import sys sys def gcd(x, y):
  if y == 1:
    return 1
  elif y == 0:
    return x
  else:
    return gcd(y, x % y) gcd if y == 1:
    return 1
  elif y == 0:
    return x
  else:
    return gcd(y, x % y) y == 1 y 1 return 1 1 elif y == 0:
    return x
   y == 0 y 0 return x x return gcd(y, x % y) gcd(y, x % y) gcd y x % y x y x x y y line = sys.stdin.readline() line sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline (a, b) = line.split() (a, b) a b line.split() line.split line split a = int(a) a int(a) int a b = int(b) b int(b) int b if a > b:
  b, a = a, b a > b a b b, a = a, b b a a b print gcd(a, b) gcd a b b = int(b) int(b) b a = a, b b a line = sys.stdin.readline() sys.stdin.readline() line def gcd(x, y):
  if y == 1:
    return 1
  elif y == 0:
    return x
  else:
    return gcd(y, x % y) def gcd(x, y):
  if y == 1:
    return 1
  elif y == 0:
    return x
  else:
    return gcd(y, x % y) gcd a = int(a) int(a) a b, a = a, b a b
import sys

def gcd(x, y):
  if y == 1:
    return 1
  elif y == 0:
    return x
  else:
    return gcd(y, x % y)

line = sys.stdin.readline()
(a, b) = line.split()
a = int(a)
b = int(b)
if a > b:
  b, a = a, b

print gcd(a, b)