import java.util.Scanner;

public class CoffeeOffer {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();  // number of cups bought
        int k = sc.nextInt();  // offer condition

        if (n <= 0 || k <= 0) {
            System.out.println("-1");
        } else {
            int freeCups = n / k;  // integer division → free cups
            int totalCups = n + freeCups;
            System.out.println(totalCups);
        }

        sc.close();
    }
}
