#include <bits/stdc++.h>
using namespace std;
bool vis[10000007];
vector<int> v;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  int x = 2;
  while (n > 0 || m > 0) {
    if (x % 2 == 0 && x % 3 == 0) {
      if (m >= n) {
        m--;
      } else
        n--;
    } else if (x % 2 == 0)
      n--;
    else if (x % 3 == 0)
      m--;
    x++;
  }
  x--;
  cout << x << "\n";
  return 0;
}
