#coding: UTF-8

import sys

class Algo:
  @staticmethod
  def greatest_common_divisor(x, y):
    while True:
      r = x%y
      if r==0:
        print(y)
        break
      x, y = y, r
l = list(map(int, input().split()))
X = l[0]
Y = l[1]
Algo.greatest_common_divisor(X, Y) import sys sys class Algo:
  @staticmethod
  def greatest_common_divisor(x, y):
    while True:
      r = x%y
      if r==0:
        print(y)
        break
      x, y = y, r Algo def greatest_common_divisor(x, y):
    while True:
      r = x%y
      if r==0:
        print(y)
        break
      x, y = y, r greatest_common_divisor while True:
      r = x%y
      if r==0:
        print(y)
        break
      x, y = y, r True r = x%y r x%y x y if r==0:
        print(y)
        break
       r==0 r 0 print(y) print y break x, y = y, r x y y r x x y y @staticmethod
   greatest_common_divisor staticmethod greatest_common_divisor l = list(map(int, input().split())) l list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split X = l[0] X l[0] l 0 Y = l[1] Y l[1] l 1 Algo.greatest_common_divisor(X, Y) Algo.greatest_common_divisor Algo greatest_common_divisor X Y Y = l[1] l[1] Y class Algo:
  @staticmethod
  def greatest_common_divisor(x, y):
    while True:
      r = x%y
      if r==0:
        print(y)
        break
      x, y = y, r class Algo:
  @staticmethod
  def greatest_common_divisor(x, y):
    while True:
      r = x%y
      if r==0:
        print(y)
        break
      x, y = y, r Algo X = l[0] l[0] X l = list(map(int, input().split())) list(map(int, input().split())) l
#coding: UTF-8

import sys

class Algo:
  @staticmethod
  def greatest_common_divisor(x, y):
    while True:
      r = x%y
      if r==0:
        print(y)
        break
      x, y = y, r
l = list(map(int, input().split()))
X = l[0]
Y = l[1]
Algo.greatest_common_divisor(X, Y)