import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int minDate = 0; if (n == 2 || m == 2 || (m == 3 && n % m == 2)) { minDate = -1; } else if (n <= m){ minDate = 1; } else if (n % m == 0){ for (int i = 0 ; i < n / m ; i++) { minDate++; } } else if (n % m >= 1) { for (int i = 0 ; i < (n / m) + 1 ; i++) { minDate++; } } System.out.println(minDate); } }