/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
using ll = int64_t;
using ull = uint64_t;
using ld = long double;
using uint = uint32_t;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
/*-----------------------------------------------------------------------------------------------------*/
#define int ll
signed main() { EmiliaMyWife
	int n, m, k;
	cin >> n >> m >> k;
	vector<pair<int, int>> seg(m);
	for(int i = 0; i < m; i++)
		cin >> seg[i].first >> seg[i].second, seg[i].first--;
	ll ans = 0;
	vector<int> owo(m), d(n * 3 + 1);
	for(int i = k; i <= n + 1; i++) {
		int r = i, l = i - k;
		for(int j = 0; j <= n + 1; j++)
			d[j] = 0;
		for(int j = 0; j < m; j++)
			owo[j] = max<ll>(0, min({r - seg[j].first, seg[j].second - l, r - l, seg[j].second - seg[j].first}));
		ll res = 0;
		//cout << "here " << l << ' ' << r << '\n';
		for(int j = 0; j < m; j++) {
			res += owo[j];
			//if(j == m -1)
				//continue;
			//cout << owo[j] << " \n"[j == m - 1];
			///*
			if(seg[j].first + owo[j] + 1 <= i)
				continue;
			d[seg[j].first + owo[j] + 1]++;
			d[seg[j].first + k + 1]--;
			d[seg[j].second + 1]--;
			d[seg[j].second + (k - owo[j]) + 1]++;
		//*/
		}
		for(int j = i + 1, cur = 0; j <= n + 1; j++) {
			cur += d[j], res += cur, ans = max(res, ans);
			//cout << "here " << j - k << ' ' << j << ' ' << cur << ' ' << res << '\n';
		}
		ans = max(ans, res);
	}
	cout << ans << '\n';
}
