#include <bits/stdc++.h>
using namespace std;
const char lend = '\n';
int good(int k, int n, int m) {
  int a, b, c;
  c = k / 6;
  a = k / 2 - c;
  b = k / 3 - c;
  n = max(0, n - a);
  m = max(0, m - b);
  return n + m <= c;
}
int main() {
  ios::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  for (int i = 2;; ++i) {
    if (good(i, n, m)) {
      cout << i << endl;
      break;
    }
  }
}
