#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
const double PI  = 3.1415926535897932384626433832795028841971;
const int    INF = 1000000007;
const double EPS = 1e-10;
const int    MOD = 1000000007;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> PP;

ll T, n;
ll s[100000], t[100000];
ll sum[100001];

int main(){
    cin >> T >> n;
    rep(i,n){
        cin >> s[i] >> t[i];
        sum[i+1] += t[i]-s[i]+sum[i];
    }
    ll ans = 0;
    rep(i,n){
        ll cnt = 0;
        int st = i, en = n, mid;
        while(en-st > 1){
            mid = (st+en)/2;
            if(s[mid] <= s[i]+T) st = mid;
            else en = mid;
        }
        cnt = sum[st]-sum[i]+min(t[st],s[i]+T)-s[st];
        ans = max(ans,cnt);
    }
    cout << ans << endl;
}