#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
const int inf = INT_MAX / 2;
int n, m;
bool check(int x) {
  int num1 = x / 2;
  int num2 = x / 3;
  int num3 = x / 6;
  if (num1 < n || num2 < m || num1 + num2 - num3 < m + n) return false;
  return true;
}
int main(void) {
  scanf("%d%d", &(n), &(m));
  int l = 0, r = 6e7;
  int ans;
  while (l <= r) {
    int mid = (l + r) >> 1;
    if (check(mid)) {
      ans = mid;
      r = mid - 1;
    } else {
      l = mid + 1;
    }
  }
  printf("%d\n", ans);
  return 0;
}
