#include <bits/stdc++.h>
using namespace std;
int n, m;
int jud(int x) {
  if (x / 2 < n || x / 3 < m || x / 2 + x / 3 - x / 6 < m + n) return 0;
  return 1;
}
int main() {
  cin >> n >> m;
  int l = 0, r = 10000000, mid;
  while (l < r) {
    mid = (l + r) / 2;
    if (jud(mid))
      r = mid;
    else
      l = mid + 1;
  }
  cout << r << endl;
  return 0;
}
