#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  int l = 0, u = 10000000, m;
  while (l + 1 < u) {
    m = (u + l) / 2;
    int x = a, y = b;
    x = x - 2 * (m / 6);
    if (x < 0)
      x = 0;
    else
      x = x - ((m % 6) / 2);
    if (x < 0) x = 0;
    y = y - (m / 6);
    if (y < 0)
      y = 0;
    else
      y = y - ((m % 6) / 3);
    if (y < 0) y = 0;
    if (x + y > m / 6) {
      l = m;
    } else
      u = m;
  }
  cout << l + 1 << endl;
}
