#include<stdio.h>
int main()
{int a,b,c;
scanf("%d%d",&a,&b);
c=a<b?a:b;
for(;;c--)
if(a%c==0&&b%c==0)break;
printf("%d\n",c);
return 0;
}
#include<stdio.h>
int main()
{int a,b,c;
scanf("%d%d",&a,&b);
do
{c=a%b;
a=b;
b=c;
}while(c);
printf("%d\n",a);
return 0;
}