#include <bits/stdc++.h>
const int INF = 2147483647;
const int MOD = 1000000007;
const long long INF64 = 9223372036854775807;
const long double EPS = 1e-7;
using namespace std;
int n, m;
bool check(int x) {
  return (x / 2 >= n && x / 3 >= m && x / 2 + x / 3 - x / 6 >= n + m);
}
int main() {
  scanf("%d%d", &n, &m);
  int l = 1, r = INF / 2;
  while (l <= r) {
    int m = (l + r) / 2;
    if (check(m))
      r = m - 1;
    else
      l = m + 1;
  }
  printf("%d\n", l);
  return 0;
}
