#include <bits/stdc++.h>
using namespace std;
int n, m;
int f(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 0;
  else
    return 1;
}
int main() {
  while (scanf("%d%d", &n, &m) != EOF) {
    int l = 0, r = 1e7;
    int ans;
    while (l <= r) {
      int mid = (l + r) / 2;
      if (f(mid))
        ans = mid, r = mid - 1;
      else
        l = mid + 1;
    }
    printf("%d\n", ans);
  }
}
