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