#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e9 + 7;
const int N = 2e2 + 10;
int main() {
  int n, m;
  cin >> n >> m;
  int l = 1, r = INF;
  int ans = 0;
  while (l <= r) {
    int mid = (r + l) / 2;
    int z = mid / 6;
    int x = mid / 2 - z;
    int y = mid / 3 - z;
    if (z >= max(0, n - x) + max(0, m - y))
      ans = mid, r = mid - 1;
    else
      l = mid + 1;
  }
  cout << ans << endl;
  return 0;
}
