#include <bits/stdc++.h>
using namespace std;
int cnt, k1, k2, n, m;
void solve() {
  int d = min(n, m) / 6 - cnt;
  if (n <= m)
    while (n <= m && d > 0) {
      d--;
      cnt++;
      n += 2;
    }
  else
    while (n > m && d > 0) {
      d--;
      cnt++;
      m += 3;
    }
}
int main() {
  while (cin >> n >> m) {
    cnt = 0;
    n *= 2;
    m *= 3;
    while (1) {
      if (cnt == min(n / 6, m / 6)) break;
      solve();
    }
    cout << max(n, m) << endl;
  }
  return 0;
}
