#include <iostream>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int search(int a,int b){
if(a%b==0) return b;
else search(b,a%b);
}
int main(int argc, char** argv) {
int a,b;
cin>>a>>b;
cout<<search(a,b);
return 0;
}