#include <bits/stdc++.h>
using namespace std;
int n, m;
bool qwq(int x) {
  int a = x / 6, b = x / 2 - a, c = x / 3 - a;
  if (a + b + c < n + m || a + b < n || a + c < m) return 0;
  return 1;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  int l = 0, r = max(n, m) * 6;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (qwq(mid))
      r = mid - 1;
    else
      l = mid + 1;
  }
  cout << r + 1;
  return 0;
}
