#include <stdio.h>
#include <math.h>
int main()
{
int m,n,i;
int sum=0;
scanf("%d %d",&m,&n);
while (n!=m)
{
if (m>n)
m=m-n;
else
n=n-m;
}
printf("%d",m);
return 0;
}
#include <stdio.h>
#include <math.h>
int main()
{
int m,n,i;
int sum=0;
scanf("%d %d",&m,&n);
while (n!=m)
{
if (m>n)
m=m-n;
else
n=n-m;
}
printf("%d",m);
return 0;
}