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