import java.util.*;

public class interval {

	public static void main(String[] args) {
	
		Scanner stdin = new Scanner(System.in);
		int n = stdin.nextInt();
		pair[] arr = new pair[n];
		for (int i=0; i<n; i++) {
			int s = stdin.nextInt();
			int e = stdin.nextInt();
			arr[i] = new pair(s, e);
		}
		Arrays.sort(arr);
		
		int res = 0;
		int busy = -1;
		
		for (int i=0; i<n; i++) {
			if (arr[i].s >= busy) {
				res++;
				busy = arr[i].e;
			}
		}
		System.out.println(res);
	
	}
}

class pair implements Comparable<pair> {
	
	public int s;
	public int e;
	
	public pair(int mys, int mye) {
		s = mys;
		e = mye;
	}
	
	public int compareTo(pair other) {
		if (this.e != other.e) return this.e - other.e;
		return this.s - other.s;
	}
}