#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>

using namespace std;

int main()
{
	int N, X;
	cin >> N >> X;

	double dp[7];
	dp[0] = X, dp[1] = N - X;
	int dist = dp[0] + dp[1];

	for (int i = 2; i < 7; ++i)
	{
		dp[i] = ceil(max(dp[i - 2] / 2, dp[i - 1] / 2));
		dist += dp[i];
	}

	cout << dist << endl;

	return 0;
}