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 && (N - 1)%(K + 1)!=0 || !turn && (N - 1)%(K + 1)==0) { ans++; if (turn) turn = false; } else { if (!turn) turn = true; } } System.out.println(ans); } }