a = int(input())
hhh = []
for i in range(a):
m = input()
if i == 0:
hhh.append(m)
else:
x,y = map(int,m.split())
flag = 0
for j in range(len(hhh)):
q,w = map(int,hhh[j].split())
if (q>=x and w>=y) or (q>=y and w>=x):
hhh[j] = m
flag = 1
break
if flag == 0:
hhh.append(m)
print(len(hhh))