/**
 *    author:  tourist
 *    created: 05.01.2020 11:08:10       
**/
#include <bits/stdc++.h>

using namespace std;

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}

template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

pair<long long, long long> GetKBest(int k, double dir) {
  double low = 0, high = k;
  for (int it = 0; it < 60; it++) {
    double mid = 0.5 * (low + high);
    long long cnt = 0;
    for (int x = 0; x <= mid; x++) {
      cnt += (long long) ((mid - x) / dir);
      if (cnt >= k) break;
    }
    if (cnt >= k) {
      high = mid;
    } else {
      low = mid;
    }
  }
  long long sx = 0, sy = 0, cnt = 0;
  for (int x = 0; x <= high; x++) {
    long long cc = (long long) ((high - x) / dir);
    sx += cc * x;
    sy += cc * (cc - 1) / 2;
    cnt += cc;
  }
  if (cnt > k) {
    for (int x = 0; x <= high; x++) {
      long long cc = (long long) ((high - x) / dir);
      if ((high - x) / dir - cc < 1e-10) {
        sx -= x;
        sy -= cc - 1;
        cnt -= 1;
        if (cnt == k) {
          break;
        }
      }
    }
  }
//  debug(k, dir, sx, sy, cnt);
//  assert(cnt == k);
  return make_pair(sx, sy);
}

bool Solvable(int k, int X, int Y) {
  long long xa = -1, ya = -1;
  long long xb = -1, yb = -1;
  double low = 0, high = 1 + 2.39e-7;
  for (int it = 0; it < 50; it++) {
    double mid = 0.5 * (low + high);
    pair<long long, long long> p = GetKBest(k, mid);
    if (p.first < X) {
      xa = p.first;
      ya = p.second;
      low = mid;
    } else {
      xb = p.first;
      yb = p.second;
      high = mid;
    }
  }
  return (xa <= X && ya <= Y) || (xb <= X && yb <= Y) || (ya * (xb - X) + yb * (X - xa) <= Y * (xb - xa));
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int X, Y;
  cin >> X >> Y;
  if (X > Y) {
    swap(X, Y);
  }
  int low = 3, high = (int) 1e7;
  while (low < high) {
    int mid = (low + high + 1) >> 1;
    if (Solvable(mid, X, Y)) {
      low = mid;
    } else {
      high = mid - 1;
    }
  }
  cout << low - 1 << '\n';
  return 0;
}


Measured memory_bytes: 256