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