#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define repd(i,a,b) for (int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    ll T;
    cin >> T;
    int N;
    cin >> N;
    vector<pair<ll, ll>> A(N);
    vector<ll> B(N + 1, 0);
    rep(i, N){
        cin >> A[i].first >> A[i].second;
        if(A[i].second - A[i].first > T) B[i + 1] = T;
        else B[i + 1] = A[i].second - A[i].first;
    }
    
    ll ret = 0;
    
    int cur = 0;
    ll sum = 0;
    ll tmp = 0;
    rep(i, N){
        sum -= B[i];
        sum -= tmp;
        while(A[cur].second <= A[i].first + T && cur < N){
            sum += A[cur].second - A[cur].first;
            cur++;
        }
        if(cur < N){
            if(A[cur].first <= A[i].first + T){
                sum += A[i].first + T - A[cur].first;
                tmp = A[i].first + T - A[cur].first;
            }
        }
        ret = max(ret, sum);
//        cout << i << ":" << ret <<  endl;
    }

    output(ret, 0);
    
    return 0;
}