import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = 1000; int[] n = new int[a]; int[] k = new int[a]; int counter = 0; for(int i = 0; i < a; i++){ n[i] = sc.nextInt(); k[i] = sc.nextInt(); if((n[i] - 1) % (k[i] + 1) != 0){ counter++; } } System.out.println(counter); } }