using System;
using System.Linq;
namespace ProgrammingContest_CSharp
{
    class Program
    {
        static void Main(string[] args)
        {
            var A = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            int ans = 0;
            ans = A[0] / 2 == A[1] ? 3 * A[1] : 6 * (A[0] - A[1]) - 3 * A[1];
            Console.WriteLine(ans);
        }
    }
}