#include <bits/stdc++.h>
using namespace std;
int n, m;
bool f(int x) {
  int c2 = x / 2;
  int c3 = x / 3;
  return c2 >= n && c3 >= m && c2 + c3 - x / 6 >= n + m;
}
int main() {
  scanf("%d%d", &n, &m);
  int st = 1, nd = 1e9, ans = 1e9;
  while (st <= nd) {
    int mid = (st + nd) >> 1;
    if (f(mid)) {
      ans = min(ans, mid);
      nd = mid - 1;
    } else
      st = mid + 1;
  }
  printf("%d\n", ans);
  return 0;
}
