#!/usr/bin/python
def main():
  rem = 1
  numbers = sorted([int(x) for x in raw_input().split()])
  while rem > 0:
    rem = numbers[1] % numbers[0]
    numbers[1] = numbers[0]
    numbers[0] = rem
  print numbers[1]
main()
