#include<bits/stdc++.h>

using namespace std;

typedef long long int64;


int main()
{
  int64 L;
  int N;
  int64 S[100000], T[100000], A[200001];
  A[0] = 0;

  cin >> L;
  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> S[i] >> T[i];
    A[i + 1] = T[i] - S[i] + A[i];
  }

  int64 ret = 0, tail = 0;
  for(int i = 0; i < N; i++) {
    int64 start = S[i], end = S[i] + L - 1;
    while(tail + 1 < N && end > S[tail + 1]) ++tail;
    ret = max(ret, A[tail] - A[i] + max(0LL, min(T[tail] - 1, end) - S[tail] + 1));
  }
  cout << ret << endl;
}