n = int(input());
res = 0
for i in xrange(n):
	p, q = map(int, raw_input().split());
	if (p + 2 <= q):
	  	res += 1;
print res

d07df4ea0b24d302ec3fc352498aa287cae33775
n = int(input());
res = 0
for i in xrange(n):
	p, q = map(int, raw_input().split());
	if (p + 2 <= q):
	  	res += 1;
print res
