#include<cstdio>
#include<algorithm>
using namespace std;
const int MAXM=100005;
struct note{
long long left;
long long right;
}grass[MAXM];
bool cmp(const note a,const note b){return a.left<b.left;}
long long n,m;
inline bool pd(long long d){
long long last=grass[1].left,now=1;
for(int i=2;i<=n;i++){
if(last+d<=grass[now].right)
last+=d;
else{
while(last+d>grass[now].right&&now<m)
now++;
if(last+d>grass[now].right)return 0;
last=last+d>=grass[now].left?last+d:grass[now].left;
}
}
return 1;
}
int main(){
freopen("usaco_20Open_socdist.in","r",stdin);
freopen("usaco_20Open_socdist.out","w",stdout);
scanf("%lld%lld",&n,&m);
for(long long i=1;i<=m;i++)
scanf("%lld%lld",&grass[i].left,&grass[i].right);
sort(grass+1,grass+1+m,cmp);
long long l=0,r=grass[m].right;
while(l<r){
long long mid=(l+r)/2+1;
if(pd(mid))l=mid;
else r=mid-1;
}
printf("%lld",l);
return 0;
}