#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  while (scanf("%d%d", &n, &m) != EOF) {
    double www;
    int hyl;
    int two = 2 * n;
    int three = 3 * m;
    for (int i = 6; i <= min(two, three); i += 6) {
      if (two <= three) {
        two += 2;
      } else
        three += 3;
    }
    printf("%d\n", max(two, three));
  }
  return 0;
}
