#include <stdio.h>


int GCD(int n, int m)
{
	if (n == m){
		return (n);
	}
	if (n < m){
		return (GCD(m, n));
	}
	n %= m;
	
	return (GCD(n, m));
};

int main(void)
{
	int n, m;
	
	scanf("%d %d", &n, &m);
	
	printf("%d", GCD(n, m));
	
	return (0);
}