#include <bits/stdc++.h>
using namespace std;
const int N = 1001000;
int line[2][N], row[2][N];
int p[N << 2];
int f(int x) { return x == p[x] ? x : p[x] = f(p[x]); }
void update(int x, int y) {
  int fx = f(x), fy = f(y);
  if (fx != fy) p[fx] = fy;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  if (n < m) swap(n, m);
  int idx = 0;
  for (int i = 0; i < n; i++) {
    line[0][i] = idx++;
    line[1][i] = idx++;
  }
  for (int i = 1; i + 1 < m; i++) {
    row[0][i] = idx++;
    row[1][i] = idx++;
  }
  for (int i = 0; i < idx; i++) p[i] = i;
  for (int i = 1; i + 1 < m; i++) {
    update(line[0][i], row[0][i]);
    update(line[1][i], row[1][i]);
  }
  for (int i = m - 1; i < n; i++) {
    update(line[0][i], line[1][m + n - 2 - i]);
    update(line[0][i - m + 1], line[1][n - 1 - i]);
  }
  for (int i = 1; i + 1 < m; i++) {
    update(line[0][n - m + i], row[1][i]);
    update(line[1][n - m + i], row[0][i]);
  }
  int ret = 0;
  for (int i = 0; i < idx; i++) {
    if (f(i) == i) ret++;
  }
  printf("%d\n", ret);
  return 0;
}
