#include<iostream>
#include<cstdio>
using namespace std;
int gcd(int a,int b){
return b==0?a:gcd(b,a%b);
}
void read(){
freopen("gcd.in","r",stdin);
freopen("gcd.out","w",stdout);
}
int main(){
read();
int a,b;
scanf("%d%d",&a,&b);
cout<<gcd(a,b);
}