import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();   // cups you buy
        int k = sc.nextInt();   // “buy-k-get-1‐free” offer

        if (n <= 0 || k <= 0) {
            System.out.println("-1");
            return;
        }

        int free = n / k;            // integer division → number of free cups
        int total = n + free;        // total cups received

        System.out.println(total);
    }
}
