#include <cstdio>
#include <algorithm>
#include <cstring>
const int maxn = 2005;
using namespace std;
int n, m, k, l[maxn], r[maxn], d[maxn], ans = 0;
int addb[maxn], adde[maxn], subb[maxn], sube[maxn], s[maxn];
int main(){
	scanf("%d%d%d", &n, &m, &k);
	for (int i = 1; i <= m; i++) scanf("%d%d", l + i, r + i);
	for (int b = 1; b + k - 1 <= n; b++){
		int e = b + k - 1, tmp = 0;
		for (int i = 1; i <= m; i++){
			d[i] = max(0, min(r[i], e) - max(l[i], b) + 1);
			tmp += d[i];
		}
		// +1 l[i] + d[i] ~ min{r[i], l[i] + k - 1}
		// -1 max{r[i] + 1, l[i] + k} ~ r[i] - d[i] + k
 		for (int i = 1; i <= m; i++){
			++addb[l[i] + d[i]];
			++adde[min(r[i] + 1, min(l[i] + k, n + 1))];
			++subb[max(min(n, l[i] + k), r[i] + 1)];
			++sube[min(n + 1, r[i] - d[i] + k + 1)];
		}
		s[0] = 0;
		for (int i = 1; i <= n; i++) s[i] = s[i - 1] + addb[i] - adde[i] + sube[i] - subb[i];
		for (int i = 1; i <= n; i++) s[i] = s[i - 1] + s[i], ans = max(ans, tmp + s[i]);
		memset(addb, 0, sizeof addb);
		memset(adde, 0, sizeof adde);
		memset(subb, 0, sizeof subb);
		memset(sube, 0, sizeof sube);
	} printf("%d\n", ans);
	return 0;
}
