#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  while (scanf("%d%d", &n, &m) != EOF) {
    n *= 2;
    m *= 3;
    int i;
    for (i = 6; i <= min(n, m); i += 6) {
      if (n > m)
        m += 3;
      else
        n += 2;
    }
    printf("%d\n", max(n, m));
  }
  return 0;
}
