#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;

ll s[100000], g[100000];
int main() {
	ll t; int n; scanf("%lld%d", &t, &n);
	rep(i, n)scanf("%lld%lld", &s[i], &g[i]);
	int b = 0;
	ll sum = 0, Max = 0;
	rep(i, n) {
		while (b < n&&g[b] - s[i] <= t)sum += g[b] - s[b], b++;
		ll c = 0; if (b < n)c = max(0LL, s[i] + t - s[b]);
		Max = max(Max, sum + c);
		sum -= g[i] - s[i];
	}
	printf("%lld\n", Max);
}