#include<bits/stdc++.h>
using namespace std;
struct _{
	int l,r,mid;
	bool operator<(const _ &ob)const{
		return mid<ob.mid;
	}
};
_ a[2010];
int pre[2010][2010],suf[2010][2010];
int lft[4010];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,m,k;
	cin>>n>>m>>k;
	int i;
	for(i=1;i<=m;++i) cin>>a[i].l>>a[i].r,a[i].mid=a[i].l+a[i].r;
	sort(a+1,a+1+m);
	int j;
	for(i=1;i<=n-k+1;++i){
		for(j=1;j<=m;++j){
			pre[i][j]=pre[i][j-1]+max(min(i+k-1,a[j].r)-max(i,a[j].l)+1,0);
		}
		for(j=m;j>=1;--j){
			suf[i][j]=suf[i][j+1]+max(min(i+k-1,a[j].r)-max(i,a[j].l)+1,0);
		}
	}
	int top=0;
	for(i=0;i<=n<<1;++i){
		while(top<m){
			if(a[top+1].mid<=i) ++top;
			else break;
		}
		lft[i]=top;
	}
	int ans=0;
	for(i=1;i<=n-k+1;++i){
		for(j=i;j<=n-k+1;++j){
			ans=max(ans,pre[i][lft[i+j+k-1]]+suf[j][lft[i+j+k-1]+1]);
		}
	}
	cout<<ans<<'\n';//agasdggasdg
	return 0;
}