#include <iostream>
#include <algorithm>
using namespace std;
int N; long long T, a[200009], sum[100009];
int main() {
	cin >> T >> N;
	for (int i = 0; i < 2 * N; i += 2) cin >> a[i] >> a[i + 1];
	for (int i = 0; i < N; i++) sum[i + 1] = sum[i] + a[i * 2 + 1] - a[i * 2];
	long long ret = 0;
	for (int i = 0; i < 2 * N; i += 2) {
		int ptr = lower_bound(a, a + 2 * N, a[i] + T) - a - 1;
		long long res = 0;
		if (ptr % 2 == 0) res = sum[ptr / 2] - sum[i / 2] + (a[i] + T) - a[ptr];
		else res = sum[ptr / 2 + 1] - sum[i / 2];
		ret = max(ret, res);
	}
	cout << ret << endl;
	return 0;
}