Students in a class are making towers of blocks. Each student makes a (non-zero) tower by stacking pieces lengthwise on top of each other. n of the students use pieces made of two blocks and m of the students use pieces made of three blocks.

The students don’t want to use too many blocks, but they also want to be unique, so no two students’ towers may contain the same number of blocks. Find the minimum height necessary for the tallest of the students' towers.

Input

The first line of the input contains two space-separated integers n and m (0 ≤ n, m ≤ 1 000 000, n + m > 0) — the number of students using two-block pieces and the number of students using three-block pieces, respectively.

Output

Print a single integer, denoting the minimum possible height of the tallest tower.

Examples

Input

1 3


Output

9


Input

3 2


Output

8


Input

5 0


Output

10

Note

In the first case, the student using two-block pieces can make a tower of height 4, and the students using three-block pieces can make towers of height 3, 6, and 9 blocks. The tallest tower has a height of 9 blocks.

In the second case, the students can make towers of heights 2, 4, and 8 with two-block pieces and towers of heights 3 and 6 with three-block pieces, for a maximum height of 8 blocks.
#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";
}
