#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
int gcd (int a, int b) {
return b ? gcd (b, a % b) : a;
}
signed main() {
int x,y;
cin >> x >> y;
cout << gcd(x,y);
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
int gcd (int a, int b) {
return b ? gcd (b, a % b) : a;
}
signed main() {
int x,y;
cin >> x >> y;
cout << gcd(x,y);
}