#include<bits/stdc++.h> using namespace std; int main(){ int bc,c; cin>>bc>>c; while(bc%c!=0){ int y=bc%c; bc=c; c=y; } cout<<c; return 0; }