#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  int max3 = 3 * m;
  int max2 = 2 * (m / 2 + n);
  int ans;
  int k = m / 2;
  do {
    ans = max(max2, max3);
    if (max2 && k) {
      k--;
      max2 -= 2;
      max3 += 3;
      if (max3 % 2 == 0) max3 += 3;
    }
  } while (max(max2, max3) < ans);
  cout << ans << endl;
  return 0;
}
