def fn():
n = 10
matrix = [[5, 14], [14, 17], [8, 13], [13, 15], [15, 17], [3, 6], [4, 7], [6, 9], [11, 14], [10, 11]]
print(matrix)
matrix = sorted(matrix, key = lambda x: x[1])
curr = matrix[0][1]
count = 1
for i in range(1, n):
if matrix[i][0]>=curr:
curr = matrix[i][1]
count+=1
print("Count =", count)
fn()
ZGVmIGZuKCk6CiAgICBuID0gMTAKICAgIG1hdHJpeCA9IFtbNSwgMTRdLCBbMTQsIDE3XSwgWzgsIDEzXSwgWzEzLCAxNV0sIFsxNSwgMTddLCBbMywgNl0sIFs0LCA3XSwgWzYsIDldLCBbMTEsIDE0XSwgWzEwLCAxMV1dCiAgICBwcmludChtYXRyaXgpCiAgICBtYXRyaXggPSBzb3J0ZWQobWF0cml4LCBrZXkgPSBsYW1iZGEgeDogeFsxXSkKICAgIGN1cnIgPSBtYXRyaXhbMF1bMV0KICAgIGNvdW50ID0gMQogICAgZm9yIGkgaW4gcmFuZ2UoMSwgbik6CiAgICAgICAgaWYgbWF0cml4W2ldWzBdPj1jdXJyOgogICAgICAgICAgIGN1cnIgPSBtYXRyaXhbaV1bMV0KICAgICAgICAgICBjb3VudCs9MQogICAgcHJpbnQoIkNvdW50ID0iLCBjb3VudCkKZm4oKQ==
[[5, 14], [14, 17], [8, 13], [13, 15], [15, 17], [3, 6], [4, 7], [6, 9], [11, 14], [10, 11]]
Count = 5