#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/stack:16000000")
#pragma warning(disable : 4996)
const int inf = 1 << 25;
const double eps = 1e-9;
int solve(int n, int m) {
  if (n > m) swap(n, m);
  vector<bool> chosen(n, false);
  int ans = 0;
  for (int i = (0); i < (n); ++i)
    if (!chosen[i]) {
      ++ans;
      int j = i;
      chosen[i] = true;
      while (1) {
        j += 2 * (m - 1);
        j %= 2 * (n - 1);
        int j1 = j;
        if (j1 >= n) {
          j1 %= (n - 1);
          j1 = n - j1 - 1;
        }
        if (chosen[j1]) break;
        chosen[j1] = true;
      }
      j = i;
      while (1) {
        j -= 2 * (m - 1);
        j %= 2 * (n - 1);
        j += 2 * (n - 1);
        j %= 2 * (n - 1);
        int j1 = j;
        if (j1 >= n) {
          j1 %= (n - 1);
          j1 = n - j1 - 1;
        }
        if (chosen[j1]) break;
        chosen[j1] = true;
      }
    }
  return ans;
}
int gcd(int a, int b) { return !b ? a : gcd(b, a % b); }
int cor(int n, int m) { return gcd(n - 1, m - 1) + 1; }
int main() {
  int n, m;
  cin >> n >> m;
  cout << solve(n, m);
  return 0;
}
