def merge(q):
st=q[0][0]
ed=q[0][1]
for l,r in a:
if r<=ed:
pass
if l<=ed and r>ed:
ed=r
if l>ed:
array.append((l,r))
st=l
ed=r
if __name__=="__main__":
n=int(input())
a=[]
array=[]
for i in range(n):
l,r=map(int,input().split())
a.append((l,r))
a=sorted(a)
merge(a)
print(len(array)+1)