#include <bits/stdc++.h>
using namespace std;
long long int max(long long int a, long long int b) {
  if (a > b) return a;
  return b;
}
long long int min(long long int a, long long int b) {
  if (a < b) return a;
  return b;
}
string sing(char x) {
  string s(1, x);
  return s;
}
bool cmpDec(long long int a, long long int b) {
  if (a >= b) return true;
  return false;
}
void print1D(long long int a[], long long int n) {
  for (long long int i = 0; i < n; i++) cout << a[i] << " ";
  cout << "\n";
}
void print2D(long long int **dp, long long int n, long long int m) {
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < m; j++) cout << dp[i][j] << " ";
    cout << "\n";
  }
}
long long int gcd(long long int a, long long int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long int logBase(long long int m, long long int b) {
  long long int count = 0;
  while (m > 1) {
    ++count;
    m = m / b;
  }
  return count;
}
typedef struct num {
  long long int index;
  long long int value;
} num;
void SUM(long long int *a, long long int n) {
  long long int sum = 0;
  for (long long int i = 0; i < n; i++) sum += a[i];
  cout << sum << "\n";
}
void addEdge(vector<long long int> adj[], long long int u, long long int v) {
  adj[u].push_back(v);
  adj[v].push_back(u);
}
void printGraph(vector<long long int> adj[], long long int V) {
  for (long long int v = 1; v < V; ++v) {
    cout << "\n Adjacency list of vertex " << v << "\n head (" << v << ")";
    for (long long int x = 0; x < adj[v].size(); x++)
      cout << " -> " << adj[v][x];
    printf("\n");
  }
}
bool cycle(vector<long long int> adj[], long long int vis[], long long int n,
           long long int parent) {
  vis[n] = 1;
  if (adj[n].empty()) return false;
  bool value = false;
  for (long long int i = 0; i < adj[n].size(); i++) {
    if (adj[n][i] != parent) {
      if (vis[adj[n][i]] == 1)
        return true;
      else
        value |= cycle(adj, vis, adj[n][i], n);
    }
  }
  return value;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, m;
  cin >> n >> m;
  long long int a, b;
  long long int k;
  a = n * 2;
  b = m * 3;
  long long int ans = max(a, b);
  k = min(a / 6, b / 6);
  for (long long int i = 0; i < k; i++) {
    if (a + 2 < b + 3)
      a += 2;
    else
      b += 3;
    k = min(a / 6, b / 6);
  }
  ans = max(a, b);
  cout << ans << "\n";
}
