import java.util.*; public class Run { public static void main (String arg[]) { Scanner scan = new Scanner(System.in); int ans = 0; int n = 1000; double N, K; boolean turn = true; for (int i = 0; i < n; i++) { N = scan.nextDouble(); K = scan.nextDouble(); if (turn) { if (N > K) { ans++; turn = false; } else if ((N - 1)%(K + 1)==0) { ans++; turn = false; } } else { if (N > K) turn = true; else if ((N - 1)%(K + 1)!=0) { ans++; } else turn = true; } } System.out.println(ans); } }