Start: Jul, 05, 2019 08:40:00
2019年度暑期短学期达标测试
End: Jul, 05, 2019 11:40:00
Time elapsed:
Time remaining:

Problem_ID: F
Result: Accepted
Time: 87ms
Memory: 25312kB
Author: CT12813021281
In contest: 1281

n=int(input())
lst1=[]
lst2=[]
for i in range(n):
    lst1.append([])
    a,b=map(int,input().split())
    lst1[i].append(a)
    lst1[i].append(b)
if n==1:
    print("1")
else:
    lst2.append(lst1[0])
    for i in range(1,n):
        flag=0
        for j in range(0,len(lst2)):
            if lst1[i][0]<=lst2[j][0] and lst1[i][1]<=lst2[j][1]:
                lst2[j]=lst1[i]
                flag=1
                break
            elif lst1[i][0]<=lst2[j][1] and lst1[i][1]<=lst2[j][0]:
                lst2[j]=lst1[i]
                flag=1
                break
        if flag==0:
            lst2.append(lst1[i])
print(len(lst2))