#include #include #include using namespace std; const int maxn=2505; struct Cow { int L,R; }; inline bool operator<(const Cow &a,const Cow &b) { return a.L>b.L; } int n,m,cnt[1005],res; Cow cow[maxn]; int main() { #ifdef local freopen("pro.in","r",stdin); #endif scanf("%d%d",&n,&m); for(int i=0;i=cow[i].L;j--) if(cnt[j]) { res++; cnt[j]--; break; } printf("%d\n",res); return 0; }