#include <stdio.h>


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

int main(void)
{
	int n, m;
	
	scanf("%d %d", &n, &m);
	
	printf("%d", n > m ? GCD(n, m) : GCD(m, n));

	return (0);
}