#include<iostream>
#include<stdio.h>
using namespace std; int main()
{
//freopen("acm.acm","r",stdin);
int tree;
int num;
int sum;
int a,b;
while()
{
cin>>tree;
cin>>num;
if(!tree && !num)
break;
++ tree;
sum = ;
while(num --)
{
cin>>a;
cin>>b;
sum += b - a + ;
}
cout<<tree - sum<<endl;
}
}