#include <bits/stdc++.h>
using namespace std;
bool check(long long int mid, long long int n, long long int m) {
  long long int temp2 = mid / 2;
  long long int temp3 = mid / 3;
  long long int temp6 = mid / 6;
  if (temp2 < n || temp3 < m) return false;
  long long int extra2 = temp2 - n;
  long long int extra3 = temp3 - m;
  if (extra2 + extra3 >= temp6) return true;
  return false;
}
int func(int n, int m) {
  long long int beg = 2, mid, last = 1000000000;
  while (beg < last) {
    mid = beg + (last - beg) / 2;
    if (check(mid, n, m))
      last = mid;
    else
      beg = mid + 1LL;
  }
  return last;
}
int main() {
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  cout << func(n, m) << endl;
  return 0;
}
