#include <bits/stdc++.h>
using namespace std;
const int maxn = 150000 + 7;
const long long mod = 1e9 + 7;
const long long INF = 5e18 + 7;
const int inf = 1e9 + 7;
const long long maxx = 1e6 + 700;
int main() {
  int n, m, i;
  scanf("%d%d", &n, &m);
  i = max(2 * n, 3 * m);
  while (i / 2 + i / 3 - i / 6 < n + m || i / 2 < n || i / 3 < m) {
    i++;
  }
  printf("%d", i);
  return 0;
}
