#include <bits/stdc++.h>
using namespace std;
int n, m;
bool can(int x) {
  int kol = x / 6;
  int kek = x / 3 - kol;
  int sas = x / 2 - kol;
  int nn = n - sas;
  int mm = m - kek;
  if (max(nn, 0) + max(mm, 0) <= kol)
    return true;
  else
    return false;
}
int main() {
  cin >> n >> m;
  int l = 0;
  int r = 10000000;
  while (r - l > 1) {
    int mid = (l + r) / 2;
    if (can(mid))
      r = mid;
    else
      l = mid;
  }
  if (can(l)) r = l;
  cout << r << endl;
}
