#include<iostream>#include<algorithm>#defineinf0x3f3f3f3f#defineendEnDusingnamespace std;constint N =100010;structnode{int l, r;booloperator<(const node& o)const{return l < o.l;}};int n, beg, end;
node a[N];intmain(){
cin >> beg >> end >> n;// [beg, end]for(int i =1; i <= n;++ i) cin >> a[i].l >> a[i].r;sort(a +1, a + n +1);int res =0;bool flag =false;for(int i =1; i <= n;++ i){int j = i, max_r =-inf;while(j <= n && a[j].l <= beg){
max_r =max(max_r, a[j].r);++ j;}if(max_r < beg){
flag =false;break;}++ res;if(max_r >= end){
flag =true;break;}
beg = max_r;
i = j -1;}
cout << res << endl;return0;}