// #牛客春招刷题训练营# https://www.nowcoder.com/discuss/726480854079250432
// 模拟题
#include <iostream>
using namespace std;
int main() {
ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int n, x;
cin >> n >> x;
int a, b, ans = 0;
for (int i = 0; i < n; i++){
cin >> a >> b;
if(a - b >= x || a - b <= -x){
ans++;
}
}
cout << ans;
}
// 64 位输出请用 printf("%lld")

京公网安备 11010502036488号