#include <bits/stdc++.h>
using namespace std;

int main() {
  long a, b;
  cin >> a >> b;
  cout << gcd(a, b) << "\n";
}