#include<cstdio>
using namespace std;
int main()
{
int l,m,tree[10010]={0},a,b,s=0;
memset(tree,0,sizeof(tree));
for (int i=0;i<m;i++)
{
scanf("%d%d",&a,&b);
for(int j=a;j<=b; j++)
tree[j]=1;
}
for(int i=0;i<=1,i++);
if(tree[i]==0)s++;
printf("%d",s);
return 0;
}