Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
ass=[tuple(map(int,input().split())) for i in range(m)]
ass.sort(key=lambda x:x[1])

acum = []

for ab in ass:
    if [x for x in acum if ab[0]<x <=ab[1]] == []:
        acum =acum + [ab[1]]

print(len(acum))


Fixed submission:
n,m=map(int,input().split())
ass=[tuple(map(int,input().split())) for i in range(m)]
ass.sort(key=lambda x:x[1])

acum = []

def ifsatisfied(ab):
    for x in acum:
        if ab[0]<x <=ab[1]:
            return(True)
    return(False)

for ab in ass:
    if not ifsatisfied(ab):
        acum.append(ab[1])

print(len(acum))

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
ass=[tuple(map(int,input().split())) for i in range(m)]
ass.sort(key = lambda x:x[0])

count = 0

while ass != []:
    count = count+1
    ref = min(ass,key = lambda x:x[1])
    index = next((i for i,x in enumerate(ass) if x[0]>=ref[1]),len(ass))
    ass = ass[index::]

print(count)



Fixed submission:
n,m=map(int,input().split())
ass=[tuple(map(int,input().split())) for i in range(m)]
ass.sort(key=lambda x:x[1])

acum = []

def ifsatisfied(ab):
    for x in acum:
        if ab[0]<x <=ab[1]:
            return(True)
    return(False)

for ab in ass:
    if not ifsatisfied(ab):
        acum.append(ab[1])

print(len(acum))

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
ass=[tuple(map(int,input().split())) for i in range(m)]

count = 0

while ass != []:
    count = count+1
    ref = min(ass,key = lambda x:x[1])
    ass = [x for x in ass if x[0]>=ref[1]]

print(count)


Fixed submission:
n,m=map(int,input().split())
ass=[tuple(map(int,input().split())) for i in range(m)]
ass.sort(key=lambda x:x[1])

acum = []

def ifsatisfied(ab):
    for x in acum:
        if ab[0]<x <=ab[1]:
            return(True)
    return(False)

for ab in ass:
    if not ifsatisfied(ab):
        acum.append(ab[1])

print(len(acum))

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
ass=[tuple(map(int,input().split())) for i in range(m)]

ass.sort(key = lambda x:x[1])
count = 0

while ass != []:
    count = count+1
    ref = ass[0]
    #print('ref',ref)
    ass.sort(key = lambda x:x[0])
    #print('sortedass',ass)
    index = next((i for i,x in enumerate(ass) if x[0]>=ref[1]),len(ass) )
    ass = ass[index::]
    ass.sort(key = lambda x:x[1])
    #print(index)
    #print(ass)

print(count)



Fixed submission:
n,m=map(int,input().split())
ass=[tuple(map(int,input().split())) for i in range(m)]
ass.sort(key=lambda x:x[1])

acum = []

def ifsatisfied(ab):
    for x in acum:
        if ab[0]<x <=ab[1]:
            return(True)
    return(False)

for ab in ass:
    if not ifsatisfied(ab):
        acum.append(ab[1])

print(len(acum))

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
ass=[tuple(map(int,input().split())) for i in range(m)]

ass.sort(key = lambda x:x[1])
count = 0

while ass != []:
    count = count+1
    ref = ass[0]
    #print('ref',ref)
    ass.sort(key = lambda x:x[0])
    #print('sortedass',ass)
    index = next((x for x in list(enumerate(ass)) if x[1][0]>=ref[1]),(len(ass)+10,0) )[0]
    ass = ass[index::]
    ass.sort(key = lambda x:x[1])
    #print(index)
    #print(ass)

print(count)


Fixed submission:
n,m=map(int,input().split())
ass=[tuple(map(int,input().split())) for i in range(m)]
ass.sort(key=lambda x:x[1])

acum = []

def ifsatisfied(ab):
    for x in acum:
        if ab[0]<x <=ab[1]:
            return(True)
    return(False)

for ab in ass:
    if not ifsatisfied(ab):
        acum.append(ab[1])

print(len(acum))