def Euclidean(input_list):
  # print input_list
  x = input_list[1]
  y = input_list[0]
  r = x % y
  if r != 0:
    list = [r, y]
    list.sort()
    return Euclidean(list)
  else:
    return y

list = map(int, raw_input().split(" "))
list.sort()
print Euclidean(list) def Euclidean(input_list):
  # print input_list
  x = input_list[1]
  y = input_list[0]
  r = x % y
  if r != 0:
    list = [r, y]
    list.sort()
    return Euclidean(list)
  else:
    return y Euclidean x = input_list[1] x input_list[1] input_list 1 y = input_list[0] y input_list[0] input_list 0 r = x % y r x % y x y if r != 0:
    list = [r, y]
    list.sort()
    return Euclidean(list)
  else:
    return y r != 0 r 0 list = [r, y] list [r, y] r y list.sort() list.sort list sort return Euclidean(list) Euclidean(list) Euclidean list return y y input_list input_list list = map(int, raw_input().split(" ")) list map(int, raw_input().split(" ")) map int raw_input().split(" ") ().split () raw_input split " " list.sort() list.sort list sort print Euclidean(list) Euclidean list def Euclidean(input_list):
  # print input_list
  x = input_list[1]
  y = input_list[0]
  r = x % y
  if r != 0:
    list = [r, y]
    list.sort()
    return Euclidean(list)
  else:
    return y def Euclidean(input_list):
  # print input_list
  x = input_list[1]
  y = input_list[0]
  r = x % y
  if r != 0:
    list = [r, y]
    list.sort()
    return Euclidean(list)
  else:
    return y Euclidean list = map(int, raw_input().split(" ")) map(int, raw_input().split(" ")) list
def Euclidean(input_list):
  # print input_list
  x = input_list[1]
  y = input_list[0]
  r = x % y
  if r != 0:
    list = [r, y]
    list.sort()
    return Euclidean(list)
  else:
    return y

list = map(int, raw_input().split(" "))
list.sort()
print Euclidean(list)