#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
void solve(int n) {
  int m, x, y, i, j, p[300], b, k, l = 0, r = 3000000, z;
  scanf("%d", &m);
  while (r - l > 1) {
    k = (r + l) / 2;
    x = k / 2 - k / 6;
    y = k / 3 - k / 6;
    z = k / 6;
    if (max(0, n - x) + max(0, m - y) <= z)
      r = k;
    else
      l = k;
  }
  printf("%d", r);
}
int main() {
  int n, m, x, y, i, j, q = 0;
  while (scanf("%d", &n) != EOF) {
    solve(n);
    printf("\n");
  }
  return 0;
}
