# -*- coding: utf-8 -*-

import sys
import os
import math


a, b = list(map(int, input().split()))
# a?????§?????????????????????
if b > a:
    a, b = b, a

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

result = gcd(a, b)
print(result) import sys sys import os os import math math 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 b > a:
    a, b = b, a b > a b a a, b = b, a a b b a def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b) gcd if b == 0:
        return a
    else:
        return gcd(b, a % b) b == 0 b 0 return a a return gcd(b, a % b) gcd(b, a % b) gcd b a % b a b a a b b result = gcd(a, b) result gcd(a, b) gcd a b print(result) print result b = b, a a b b = list(map(int, input().split())) list(map(int, input().split())) b a, b = b, a b a a, b = list(map(int, input().split())) list(map(int, input().split())) a def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b) def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b) gcd result = gcd(a, b) gcd(a, b) result
# -*- coding: utf-8 -*-

import sys
import os
import math


a, b = list(map(int, input().split()))
# a?????§?????????????????????
if b > a:
    a, b = b, a

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

result = gcd(a, b)
print(result)