#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m, count = 0;
  cin >> n >> m;
  int max = (n * 2);
  if ((m * 3) > max) max = (m * 3);
  for (int i = 6; i <= n * 2 && i <= m * 3; i = i + 6) {
    if (((m + 1) * 3) >= ((n + 1) * 2)) {
      n = n + 1;
    } else {
      m = m + 1;
    }
  }
  if (n * 2 > m * 3)
    cout << n * 2;
  else
    cout << m * 3;
}
