using System;
using System.Collections.Generic;
class some
{
	public static void Main()
	{
		string[]kk=Console.ReadLine().Split();
		int N=int.Parse(kk[0]);
		int X=int.Parse(kk[1]);
		Console.WriteLine(4*(X)+(N-2*X)*4);
	}
}