#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int x = 1;
  while (1) {
    if (x / 2 >= n && x / 3 >= m && x / 2 + x / 3 - x / 6 >= n + m) break;
    x++;
  }
  cout << x << endl;
}
