Problem: There is an infinite board of square tiles. Initially all tiles are white.

Vova has a red marker and a blue marker. Red marker can color a tiles. Blue marker can color b tiles. If some tile isn't white then you can't use marker of any color on it. Each marker must be drained completely, so at the end there should be exactly a red tiles and exactly b blue tiles across the board.

Vova wants to color such a set of tiles that:

  * they would form a rectangle, consisting of exactly a+b colored tiles; 
  * all tiles of at least one color would also form a rectangle. 



Here are some examples of correct colorings:

<image>

Here are some examples of incorrect colorings:

<image>

Among all correct colorings Vova wants to choose the one with the minimal perimeter. What is the minimal perimeter Vova can obtain?

It is guaranteed that there exists at least one correct coloring.

Input

A single line contains two integers a and b (1 ≤ a, b ≤ 10^{14}) — the number of tiles red marker should color and the number of tiles blue marker should color, respectively.

Output

Print a single integer — the minimal perimeter of a colored rectangle Vova can obtain by coloring exactly a tiles red and exactly b tiles blue.

It is guaranteed that there exists at least one correct coloring.

Examples

Input

4 4


Output

12


Input

3 9


Output

14


Input

9 3


Output

14


Input

3 6


Output

12


Input

506 2708


Output

3218

Note

The first four examples correspond to the first picture of the statement.

Note that for there exist multiple correct colorings for all of the examples.

In the first example you can also make a rectangle with sides 1 and 8, though its perimeter will be 18 which is greater than 8.

In the second example you can make the same resulting rectangle with sides 3 and 4, but red tiles will form the rectangle with sides 1 and 3 and blue tiles will form the rectangle with sides 3 and 3.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
int allocator_pos = 0;
char allocator_memory[(int)2e8];
inline void *operator new(size_t n) {
  char *res = allocator_memory + allocator_pos;
  allocator_pos += n;
  return (void *)res;
}
inline void operator delete(void *) noexcept {}
template <class T = long long>
inline T readInt();
inline double readDouble();
inline long long readUInt();
inline int readChar();
inline void readWord(char *s);
inline bool readLine(char *s);
inline bool isEof();
inline int getChar();
inline int peekChar();
inline bool seekEof();
inline void skipBlanks();
template <class T>
inline void writeInt(T x, char end = 0, int len = -1);
inline void writeChar(int x);
inline void writeWord(const char *s);
inline void writeDouble(double x, int len = 0);
inline void flush();
static struct buffer_flusher_t {
  ~buffer_flusher_t() { flush(); }
} buffer_flusher;
static const int buf_size = 4096;
static unsigned char buf[buf_size];
static int buf_len = 0, buf_pos = 0;
inline bool isEof() {
  if (buf_pos == buf_len) {
    buf_pos = 0, buf_len = fread(buf, 1, buf_size, stdin);
    if (buf_pos == buf_len) return 1;
  }
  return 0;
}
inline int getChar() { return isEof() ? -1 : buf[buf_pos++]; }
inline int peekChar() { return isEof() ? -1 : buf[buf_pos]; }
inline bool seekEof() {
  int c;
  while ((c = peekChar()) != -1 && c <= 32) buf_pos++;
  return c == -1;
}
inline void skipBlanks() {
  while (!isEof() && buf[buf_pos] <= 32U) buf_pos++;
}
inline int readChar() {
  int c = getChar();
  while (c != -1 && c <= 32) c = getChar();
  return c;
}
inline long long readUInt() {
  int c = readChar(), x = 0;
  while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = getChar();
  return x;
}
template <class T>
inline T readInt() {
  int s = 1, c = readChar();
  T x = 0;
  if (c == '-')
    s = -1, c = getChar();
  else if (c == '+')
    c = getChar();
  while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = getChar();
  return s == 1 ? x : -x;
}
inline double readDouble() {
  int s = 1, c = readChar();
  double x = 0;
  if (c == '-') s = -1, c = getChar();
  while ('0' <= c && c <= '9') x = x * 10 + c - '0', c = getChar();
  if (c == '.') {
    c = getChar();
    double coef = 1;
    while ('0' <= c && c <= '9') x += (c - '0') * (coef *= 1e-1), c = getChar();
  }
  return s == 1 ? x : -x;
}
inline void readWord(char *s) {
  int c = readChar();
  while (c > 32) *s++ = c, c = getChar();
  *s = 0;
}
inline bool readLine(char *s) {
  int c = getChar();
  while (c != '\n' && c != -1) *s++ = c, c = getChar();
  *s = 0;
  return c != -1;
}
static int write_buf_pos = 0;
static char write_buf[buf_size];
inline void writeChar(int x) {
  if (write_buf_pos == buf_size)
    fwrite(write_buf, 1, buf_size, stdout), write_buf_pos = 0;
  write_buf[write_buf_pos++] = x;
}
inline void flush() {
  if (write_buf_pos)
    fwrite(write_buf, 1, write_buf_pos, stdout), write_buf_pos = 0;
}
template <class T>
inline void writeInt(T x, char end, int output_len) {
  if (x < 0) writeChar('-'), x = -x;
  char s[24];
  int n = 0;
  while (x || !n) s[n++] = '0' + x % 10, x /= 10;
  while (n < output_len) s[n++] = '0';
  while (n--) writeChar(s[n]);
  if (end) writeChar(end);
}
inline void writeWord(const char *s) {
  while (*s) writeChar(*s++);
}
inline void writeDouble(double x, int output_len) {
  if (x < 0) writeChar('-'), x = -x;
  int t = (int)x;
  writeInt(t), x -= t;
  writeChar('.');
  for (int i = output_len - 1; i > 0; i--) {
    x *= 10;
    t = std::min(9, (int)x);
    writeChar('0' + t), x -= t;
  }
  x *= 10;
  t = std::min(9, (int)(x + 0.5));
  writeChar('0' + t);
}
using namespace std;
vector<vector<int>> graph;
vector<int> used;
vector<int> dist;
int ans = 0;
int dfs(int u, int pr) {
  used[u] = 1;
  dist[u] = dist[pr] + 1;
  bool f = false;
  int ma = 0;
  bool g = false;
  bool g2 = false;
  for (int v : graph[u]) {
    if (used[v] == 0) {
      f = true;
      int k = dfs(v, u);
      if (k == 2) g2 = true;
      if (k == 0) g = true;
    }
  }
  if (g && dist[u] > 1) {
    ans++;
    return 2;
  }
  if (g2) return 1;
  return 0;
}
int main() {
  long long a, b;
  cin >> a >> b;
  vector<pair<long long, long long>> var1;
  vector<pair<long long, long long>> var2;
  long long s = a + b;
  for (long long i = 1; i * i <= a; i++) {
    if (a % i == 0) {
      var1.push_back({i, a / i});
    }
  }
  for (long long i = 1; i * i <= b; i++) {
    if (b % i == 0) {
      var2.push_back({i, b / i});
    }
  }
  long long mi = 1e16;
  for (long long i = 1; i * i <= s; i++) {
    if (s % i == 0) {
      long long x = i;
      long long y = s / i;
      int L = -1;
      int R = var1.size();
      while (L + 1 < R) {
        int M = (L + R) / 2;
        if (var1[M].first <= x)
          L = M;
        else
          R = M;
      }
      int l = -1;
      int r = var1.size();
      while (l + 1 < r) {
        int m = (r + l) / 2;
        if (var1[m].second <= y)
          r = m;
        else
          l = m;
      }
      if (r <= L) {
        if (mi > (x + y) * 2) mi = (x + y) * 2;
      }
      x = i;
      y = s / i;
      L = -1;
      R = var2.size();
      while (L + 1 < R) {
        int M = (L + R) / 2;
        if (var2[M].first <= x)
          L = M;
        else
          R = M;
      }
      l = -1;
      r = var2.size();
      while (l + 1 < r) {
        int m = (r + l) / 2;
        if (var2[m].second <= y)
          r = m;
        else
          l = m;
      }
      if (r <= L) {
        if (mi > (x + y) * 2) mi = (x + y) * 2;
      }
    }
  }
  cout << mi << '\n';
  return 0;
}