/*  -*- coding: utf-8 -*-
 *
 * 2801.cc: Suntan
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;
const int MAX_M = MAX_N * 2;

/* typedef */

typedef long long ll;

/* global variables */

ll as[MAX_N], bs[MAX_N], ss[MAX_N + 1];

/* subroutines */


/* main */

int main() {
  ll t;
  int n;
  scanf("%lld%d", &t, &n);

  for (int i = 0; i < n; i++) {
    scanf("%lld%lld", as + i, bs + i);
    ss[i + 1] = ss[i] + (bs[i] - as[i]);
  }

  ll maxl = 0;
  for (int i = 0; i < n; i++) {
    ll ti = as[i] + t;
    int k = upper_bound(bs, bs + n, ti) - bs;
    //printf("k=%d\n", k);

    ll l = ss[k] - ss[i];
    if (k < n && as[k] < ti) l += ti - as[k];
    if (maxl < l) maxl = l;
  }

  printf("%lld\n", maxl);
  return 0;
}

