#include <bits/stdc++.h>
using namespace std;
char _;
const int maxN = 1000 * 1000 + 5;
const int maxM = 5000 + 5;
const int mod = 1000 * 1000 * 1000 + 7;
const int base = 701;
const int SQ = 500;
const int maxL = 17;
int cnt[3];
char c[] = {'B', 'G', 'R'};
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  int lo = 0, hi = mod;
  while (hi - lo > 1) {
    int mid = (hi + lo) >> 1;
    int c1 = mid / 2;
    int c2 = mid / 3;
    int c3 = mid / 6;
    c1 -= c3;
    c2 -= c3;
    int rn = max(n - c1, 0);
    int rm = max(m - c2, 0);
    if (rn + rm <= c3)
      hi = mid;
    else
      lo = mid;
  }
  cout << hi << endl;
  return 0;
}
