以下为解题代码 (java实现)
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int count = 0;
int p = 0;
int q = 0;
for(int i = 0; i < n;i++){
p = scanner.nextInt();
q = scanner.nextInt();
scanner.nextLine();
if((q-p) >= 2){
count++;
}
}
System.out.println(count);
}
}