#include <bits/stdc++.h>
using namespace std;
int main() {
  long n, m;
  cin >> n >> m;
  long A = 2l * n;
  long B = 3l * m;
  long C = min(A, B) / 6;
  for (int c = 0; c < C; c++) {
    if (A <= B + 1) {
      A += 2;
    } else {
      B += 3;
    }
    C = min(A, B) / 6;
  }
  cout << max(A, B) << endl;
}
