function solution(routes) {
let array=routes.sort((a,b)=>a[0]-b[0])
let end=array[0][1];
let count=1;
console.log(array)
for (let i=1;i<array.length;i++){
if (end<array[i][0]){
count+=1;
end=array[i][1];
}
if (end>array[i][1]){
end=array[i][1]
}
}
return count
}