import java.util.*;
import java.io.*;
//Solution Credits: Taranpreet Singh
class Editorial{
//SOLUTION BEGIN
int n = ni(), ans = 0;
for(int i = 1; i<= n; i++){
int start = ni(), end = ni();
//If Expected ending time < actual end time, submission is judged late.
if(start+5<end)ans++;
}
pn(ans);
}
//SOLUTION ENDS
boolean multipleTC = true;
in = new FastReader();
for(int i = 1, T = (multipleTC)?ni():1; i<= T; i++)solve(i);
out.flush();
out.close();
}
new Editorial().run();
}
void p
(Object o
){out.
print(o
);} void pn
(Object o
){out.
println(o
);} void pni
(Object o
){out.
println(o
);out.
flush();} String nln
(){return in.
nextLine();} int ni
(){return Integer.
parseInt(in.
next());} long nl
(){return Long.
parseLong(in.
next());} double nd
(){return Double.
parseDouble(in.
next());} class FastReader{
public FastReader(){
}
}
while (st == null || !st.hasMoreElements()){
try{
e.printStackTrace();
}
}
return st.nextToken();
}
try{
str = br.readLine();
e.printStackTrace();
}
return str;
}
}
}
aW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5pby4qOwovL1NvbHV0aW9uIENyZWRpdHM6IFRhcmFucHJlZXQgU2luZ2gKY2xhc3MgRWRpdG9yaWFsewogICAgLy9TT0xVVElPTiBCRUdJTgogICAgdm9pZCBzb2x2ZShpbnQgVEMpIHRocm93cyBFeGNlcHRpb257CiAgICAgICAgaW50IG4gPSBuaSgpLCBhbnMgPSAwOwogICAgICAgIGZvcihpbnQgaSA9IDE7IGk8PSBuOyBpKyspewogICAgICAgICAgICBpbnQgc3RhcnQgPSBuaSgpLCBlbmQgPSBuaSgpOwogICAgICAgICAgICAvL0lmIEV4cGVjdGVkIGVuZGluZyB0aW1lIDwgYWN0dWFsIGVuZCB0aW1lLCBzdWJtaXNzaW9uIGlzIGp1ZGdlZCBsYXRlLgogICAgICAgICAgICBpZihzdGFydCs1PGVuZClhbnMrKzsKICAgICAgICB9CiAgICAgICAgcG4oYW5zKTsKICAgIH0KICAgIC8vU09MVVRJT04gRU5EUwogICAgYm9vbGVhbiBt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AgICAgICBiciA9IG5ldyBCdWZmZXJlZFJlYWRlcihuZXcgSW5wdXRTdHJlYW1SZWFkZXIoU3lzdGVtLmluKSk7CiAgICAgICAgfQogCiAgICAgICAgcHVibGljIEZhc3RSZWFkZXIoU3RyaW5nIHMpIHRocm93cyBFeGNlcHRpb257CiAgICAgICAgICAgIGJyID0gbmV3IEJ1ZmZlcmVkUmVhZGVyKG5ldyBGaWxlUmVhZGVyKHMpKTsKICAgICAgICB9CiAKICAgICAgICBTdHJpbmcgbmV4dCgpewogICAgICAgICAgICB3aGlsZSAoc3QgPT0gbnVsbCB8fCAhc3QuaGFzTW9yZUVsZW1lbnRzKCkpewogICAgICAgICAgICAgICAgdHJ5ewogICAgICAgICAgICAgICAgICAgIHN0ID0gbmV3IFN0cmluZ1Rva2VuaXplcihici5yZWFkTGluZSgpKTsKICAgICAgICAgICAgICAgIH1jYXRjaCAoSU9FeGNlcHRpb24gIGUpewogICAgICAgICAgICAgICAgICAgIGUucHJpbnRTdGFja1RyYWNlKCk7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmV0dXJuIHN0Lm5leHRUb2tlbigpOwogICAgICAgIH0KIAogICAgICAgIFN0cmluZyBuZXh0TGluZSgpewogICAgICAgICAgICBTdHJpbmcgc3RyID0gIiI7CiAgICAgICAgICAgIHRyeXsgICAgCiAgICAgICAgICAgICAgICBzdHIgPSBici5yZWFkTGluZSgpOwogICAgICAgICAgICB9Y2F0Y2ggKElPRXhjZXB0aW9uIGUpewogICAgICAgICAgICAgICAgZS5wcmludFN0YWNrVHJhY2UoKTsKICAgICAgICAgICAgfSAgIAogICAgICAgICAgICByZXR1cm4gc3RyOwogICAgICAgIH0KICAgIH0KfSA=