using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split(' ').Select(y => int.Parse(y)).ToArray();

            var n = l[0];
            var x = l[1];

            Console.Write(n * 3 - (n % x) * 3);
            
        }
    }
}
