import re

def gcd(x, y):
    if x == y:
        return x
    if x < y and y % x == 0:
        return x
    if x > y and x % y == 0:
        return y
    if x <= y:
        m = y % x
        return gcd(x, m)
    if x >= y:
        m = x % y
        return gcd(y, m)

    l = list(range(1, int(min(x, y) / 2) + 1))
    l.reverse()
    r = 1
    #for i in range(1, int(min(x, y) / 2) + 1):
    for i in l:
        if x % i == 0 and y % i == 0:
            return i
    return 1
 
x, y = map(int, re.split(' ', raw_input()))
print(gcd(x, y)) import re re def gcd(x, y):
    if x == y:
        return x
    if x < y and y % x == 0:
        return x
    if x > y and x % y == 0:
        return y
    if x <= y:
        m = y % x
        return gcd(x, m)
    if x >= y:
        m = x % y
        return gcd(y, m)

    l = list(range(1, int(min(x, y) / 2) + 1))
    l.reverse()
    r = 1
    #for i in range(1, int(min(x, y) / 2) + 1):
    for i in l:
        if x % i == 0 and y % i == 0:
            return i
    return 1
  gcd if x == y:
        return x
     x == y x y return x x if x < y and y % x == 0:
        return x
     x < y and y % x == 0 x < y x y y % x == 0 y % x y x 0 return x x if x > y and x % y == 0:
        return y
     x > y and x % y == 0 x > y x y x % y == 0 x % y x y 0 return y y if x <= y:
        m = y % x
        return gcd(x, m)
     x <= y x y m = y % x m y % x y x return gcd(x, m) gcd(x, m) gcd x m if x >= y:
        m = x % y
        return gcd(y, m)

     x >= y x y m = x % y m x % y x y return gcd(y, m) gcd(y, m) gcd y m l = list(range(1, int(min(x, y) / 2) + 1)) l list(range(1, int(min(x, y) / 2) + 1)) list range(1, int(min(x, y) / 2) + 1) range 1 int(min(x, y) / 2) + 1 int(min(x, y) / 2) int min(x, y) / 2 min(x, y) min x y 2 1 l.reverse() l.reverse l reverse r = 1 r 1 for i in l:
        if x % i == 0 and y % i == 0:
            return i
     i l if x % i == 0 and y % i == 0:
            return i
     x % i == 0 and y % i == 0 x % i == 0 x % i x i 0 y % i == 0 y % i y i 0 return i i return 1 1 x x y y x, y = map(int, re.split(' ', raw_input())) x map(int, re.split(' ', raw_input())) map int re.split(' ', raw_input()) re.split re split ' ' raw_input() raw_input y print(gcd(x, y)) print gcd(x, y) gcd x y def gcd(x, y):
    if x == y:
        return x
    if x < y and y % x == 0:
        return x
    if x > y and x % y == 0:
        return y
    if x <= y:
        m = y % x
        return gcd(x, m)
    if x >= y:
        m = x % y
        return gcd(y, m)

    l = list(range(1, int(min(x, y) / 2) + 1))
    l.reverse()
    r = 1
    #for i in range(1, int(min(x, y) / 2) + 1):
    for i in l:
        if x % i == 0 and y % i == 0:
            return i
    return 1
  def gcd(x, y):
    if x == y:
        return x
    if x < y and y % x == 0:
        return x
    if x > y and x % y == 0:
        return y
    if x <= y:
        m = y % x
        return gcd(x, m)
    if x >= y:
        m = x % y
        return gcd(y, m)

    l = list(range(1, int(min(x, y) / 2) + 1))
    l.reverse()
    r = 1
    #for i in range(1, int(min(x, y) / 2) + 1):
    for i in l:
        if x % i == 0 and y % i == 0:
            return i
    return 1
  gcd x, y = map(int, re.split(' ', raw_input())) map(int, re.split(' ', raw_input())) x y = map(int, re.split(' ', raw_input())) map(int, re.split(' ', raw_input())) y
import re

def gcd(x, y):
    if x == y:
        return x
    if x < y and y % x == 0:
        return x
    if x > y and x % y == 0:
        return y
    if x <= y:
        m = y % x
        return gcd(x, m)
    if x >= y:
        m = x % y
        return gcd(y, m)

    l = list(range(1, int(min(x, y) / 2) + 1))
    l.reverse()
    r = 1
    #for i in range(1, int(min(x, y) / 2) + 1):
    for i in l:
        if x % i == 0 and y % i == 0:
            return i
    return 1
 
x, y = map(int, re.split(' ', raw_input()))
print(gcd(x, y))