#include <bits/stdc++.h>
using namespace std;
int n, m;
long long div_by(int d, long long l) { return l / d; }
bool verific(long long l) {
  long long doi, trei, sase;
  doi = div_by(2, l);
  trei = div_by(3, l);
  sase = div_by(6, l);
  if (doi < n) return false;
  if (trei < m) return false;
  if (n + m <= doi + trei - sase) return true;
  return false;
}
void rezolva() {
  long long st, dr;
  st = 1;
  dr = 9223372036854775807 / 2;
  long long m, sol = -1;
  while (st <= dr) {
    m = (st + dr) / 2;
    if (verific(m)) {
      sol = m;
      dr = m - 1;
    } else
      st = m + 1;
  }
  cout << sol << '\n';
}
int main() {
  cin >> n >> m;
  rezolva();
  return 0;
}
