using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {

        static void Main(string[] args)
        {
           // Console.SetIn(new StreamReader("input.txt"));
            int[] inputs = In.Ints().ToArray();
            int N = inputs[0];
            int X = inputs[1];

            var ans = 2 * X + (N - X) + ((N - (2 * X)) * 5);

            Out(ans);



            return;
        } 

        private static void Out(Object arg)
        {
            Console.WriteLine(arg);
        }
    }

    class In
    {
        public static int Int()
        {
            return int.Parse(Console.ReadLine());
        }

        public static IEnumerable<int> Ints()
        {
            return Console.ReadLine().Split(' ').Select(i => int.Parse(i));
        }
    }
}
