#include <bits/stdc++.h>
using namespace std;
const int MAX = (int)500 + 5;
const int inf = (int)1e9;
const double EPS = 1e-9;
const int mod = 1000000005;
int arr[10000000];
int main() {
  cin.sync_with_stdio(false);
  cin.tie(NULL);
  int last2 = 0, last3 = 0;
  int n, m, ret;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    last2 += 2;
    arr[last2]++;
  }
  for (int i = 0; i < m; i++) {
    last3 += 3;
    arr[last3]++;
  }
  for (int i = 0; i < 10000000; i++)
    if (arr[i] == 2) {
      if (last3 + 3 <= last2 + 2) {
        last3 += 3;
        arr[last3]++;
      } else {
        last2 += 2;
        arr[last2]++;
      }
    }
  for (int i = 0; i < 10000000; i++)
    if (arr[i]) ret = i;
  cout << ret;
}
