def main():
  a, b = list(map(int, input().split()))
  if a < b:
    a, b = b, a
  while b > 1:
    r = a % b
    if r == 0:
      break
    a, b = b, r

  print(b)

  return 0


if __name__ == '__main__':
  main() def main():
  a, b = list(map(int, input().split()))
  if a < b:
    a, b = b, a
  while b > 1:
    r = a % b
    if r == 0:
      break
    a, b = b, r

  print(b)

  return 0 main a, b = list(map(int, input().split())) a list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split b if a < b:
    a, b = b, a
   a < b a b a, b = b, a a b b a while b > 1:
    r = a % b
    if r == 0:
      break
    a, b = b, r

   b > 1 b 1 r = a % b r a % b a b if r == 0:
      break
     r == 0 r 0 break a, b = b, r a b b r print(b) print b return 0 0 if __name__ == '__main__':
  main() __name__ == '__main__' __name__ '__main__' main() main def main():
  a, b = list(map(int, input().split()))
  if a < b:
    a, b = b, a
  while b > 1:
    r = a % b
    if r == 0:
      break
    a, b = b, r

  print(b)

  return 0 def main():
  a, b = list(map(int, input().split()))
  if a < b:
    a, b = b, a
  while b > 1:
    r = a % b
    if r == 0:
      break
    a, b = b, r

  print(b)

  return 0 main
def main():
  a, b = list(map(int, input().split()))
  if a < b:
    a, b = b, a
  while b > 1:
    r = a % b
    if r == 0:
      break
    a, b = b, r

  print(b)

  return 0


if __name__ == '__main__':
  main()