#include <bits/stdc++.h>
using namespace std;
void swap(long long int &a, long long int &b) {
  auto tm = a;
  a = b;
  b = tm;
}
long long int power(long long int x, long long int y) {
  long long int sum = 1;
  for (long long int i = 0; i < y; i++) sum *= x;
  return sum;
}
long long int fact(long long int n) {
  long long int res = 1;
  for (long long int i = 2; i <= n; i++) res = res * i;
  return res;
}
long long int nCr(long long int n, long long int r) {
  return fact(n) / (fact(r) * fact(n - r));
}
vector<long long int> adj[200005];
bool vis[200005] = {false};
long long int s[200005] = {0};
long long int k, a[200005] = {0};
long long int ans;
void bfs(long long int node) {
  vis[node] = true;
  for (auto &(i) : adj[node]) {
    if (!vis[i]) {
      bfs(i);
      s[node] += s[i];
      if (s[node] >= k && a[node] == 1) ans = node;
    }
  }
}
void solve() {
  long long int n, i, j;
  long long int m, x, y, z;
  cin >> n >> m;
  for (i = 1;; i++) {
    x = i / 2;
    y = i / 3;
    z = i / 6;
    if ((x + y - z) >= (n + m) && x >= n && y >= m) {
      cout << i;
      return;
    }
  }
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int tt = 1.0 * clock();
  int t;
  t = 1;
  for (int y = 0; y < t; y++) {
    solve();
    cout << endl;
  }
}
