#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const int nmax = 200010;
const int mmax = 10010;
const int cmax = 1000010;
const int sigma_size = 150;
const int inf = 1e9 + 7;
const int modulo = 1e4 + 7;
const double linf = 1e36;
int n, m;
int main() {
  scanf("%d%d", &n, &m);
  int l = 1, r = 1e8, mid;
  while (l < r) {
    mid = (l + r) / 2;
    if (mid / 2 >= n && mid / 3 >= m && mid / 2 + mid / 3 - mid / 6 >= n + m)
      r = mid;
    else
      l = mid + 1;
  }
  printf("%d\n", r);
  return 0;
}
