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