#include <bits/stdc++.h>
#define ll long long
using namespace std;
int l[2100];
int r[2100];
int inc[2101];
int intersect_interval(int a, int b, int c, int d) {
    int starting = max(a,c);
    int ending = min(b,d);
    return max(0, ending-starting);
}
int solo[2100];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n,m,k; cin>>n>>m>>k;

    for(int j=0; j<m; j++) {cin>>l[j]>>r[j]; r[j]++;} // exclusive right endpoint
    for(int i=1; i<=n; i++) {
        solo[i] = 0;
        for(int j=0; j<m; j++) {
            solo[i] += intersect_interval(l[j], r[j], i, i+k);
        }
    }
    // solo[i] gives the value if he is the only person talking
    int ans = 0;
    for(int i=1; i<=n-k+1; i++) { // i indicates the "first" person
        // start slope trick
        for(int s=0; s<2100; s++) {inc[s]=0;}
        // editorial lasts from i to i+k-1 incl
        int tmp = solo[i];
        // now lets look at the second author
        for(int j=0; j<m; j++) {
            if(r[j]<i+k || l[j]<=i) continue; // never listening to the second one
            inc[r[j]-k]--;
            inc[l[j]]--;
            if(l[j]<i+k) {
                inc[i]++;
                inc[r[j]-i-k+l[j]]++;
            } else {
                //cout << "disjoint case: " << i << " " << j << "\n";
                inc[l[j]-k]++;
                inc[r[j]]++;
            }
        }
        ans = max(ans, tmp);
        // second author tries s=i, clearly he gets nothing
        int delta = 0;
        for(int s=i; s<=n-k+5; s++) {
            delta += inc[s];
            tmp += delta;
            ans = max(tmp, ans);
            //cout << i << " " << s << " " << tmp << " " << delta << "\n";
        }

    }
    cout << ans << "\n";
}
