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

namespace ConsoleApplication13
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string[] values = s.Split(' ');
            int n = int.Parse(values[0]);
            int a = int.Parse(values[1]);
            int o = n - 3 * a;
            if (n < a * 3)
                Console.WriteLine(-1);
        }
    }
}