def main():

    N, M = list(map(int, input().split()))

    a_b = sorted([list(map(int, input().split())) for _ in range(M)])

    used = [0] * M

    ans = 0

    for i in range(M):

        k = M - i - 1

        if used[k]:

            continue

        used[k], c = 1, a_b[k][0]

        for j in range(k):

            if a_b[j][0] <= c < a_b[j][1]:

                used[j] = 1

        ans += 1

    print(ans)



if __name__ == "__main__":

    main()

import sys

input = sys.stdin.readline



def main():

    N, M = list(map(int, input().split()))

    a_b = sorted([list(map(int, input().split())) for _ in range(M)])

    used = [0] * M

    ans = 0

    for i in range(M):

        k = M - i - 1

        if used[k]:

            continue

        used[k], c = 1, a_b[k][0]

        for j in range(k):

            if a_b[j][0] <= c < a_b[j][1]:

                used[j] = 1

        ans += 1

    print(ans)



if __name__ == "__main__":

    main()
def main():
    N, M = list(map(int, input().split()))
    a_b = sorted([list(map(int, input().split())) for _ in range(M)])
    used = [0] * M
    ans = 0
    for i in range(M):
        k = M - i - 1
        if used[k]:
            continue
        used[k], c = 1, a_b[k][0]
        for j in range(k):
            if a_b[j][0] <= c < a_b[j][1]:
                used[j] = 1
        ans += 1
    print(ans)


if __name__ == "__main__":
    main()

import sys

input = sys.stdin.readline


def main():
    N, M = list(map(int, input().split()))
    a_b = sorted([list(map(int, input().split())) for _ in range(M)])
    used = [0] * M
    ans = 0
    for i in range(M):
        k = M - i - 1
        if used[k]:
            continue
        used[k], c = 1, a_b[k][0]
        for j in range(k):
            if a_b[j][0] <= c < a_b[j][1]:
                used[j] = 1
        ans += 1
    print(ans)


if __name__ == "__main__":
    main()

+import sys + +input = sys.stdin.readline + +