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