#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef long long ll;
typedef unsigned long long llu;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
typedef pair<char, int> pci;
typedef pair<int, char> pic;
const int MOD = 998244353;
const long double PI = 3.141592653589793238462643383279502884197;

ll fac[1] = {1}, inv[1] = {1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll mp(ll a,ll b){ll ret=1;while(b){if(b&1)ret=ret*a%MOD;a=a*a%MOD;b>>=1;}return ret;}
ll cmb(ll r, ll c) {return (c>r||c<0) ? 0:fac[r] * inv[c] % MOD * inv[r - c] % MOD;}

int psum[6005];
pii vec[2000];

int main() {
    int n, m, k;
    scanf("%d %d %d", &n, &m, &k);

    for (int i = 0; i < m; i++) scanf("%d %d", &vec[i].first, &vec[i].second);

    // 어디까지 쟤야 하는 지 확실히 계산해야 하는데...

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        int now = 0, miv, mav;
        pii me = {i, i + k  - 1};
        memset(psum, 0, sizeof(psum));

        for (int j = 0; j < m; j++) {
            if (me.first > vec[j].second) continue;

            miv = min(me.second, vec[j].second);
            mav = max(me.first, vec[j].first);

            int ry = max(0, miv - mav + 1);
            now += ry;

            if (ry == 0) {
                if (vec[j].second - vec[j].first + 1 > k) {
                    psum[vec[j].first - k + 1]++;
                    psum[vec[j].first + 1]--;
                    psum[vec[j].second - k + 1 + 1]--;
                    psum[vec[j].second + 1 + 1]++;
                }
                else {
                    psum[vec[j].first - k + 1]++;
                    psum[vec[j].second - k + 1 + 1]--;
                    psum[vec[j].first + 1]--;
                    psum[vec[j].second + 1 + 1]++;
                }
            }
            else {
                if (me.first >= vec[j].first || ry >= vec[j].second - vec[j].first + 1 || ry >= me.second - me.first + 1) continue;
                if (me.second >= vec[j].second) continue;

                int x = vec[j].second - me.second;

                // printf("%d / %d\n", i, j);
                if (vec[j].second - vec[j].first + 1 > k) {
                    psum[me.second - k + 1 + 1]++;
                    psum[vec[j].first + 1]--;
                    psum[vec[j].second - k + 1 + 1]--;
                    psum[vec[j].first + x + 1]++;
                }
                else {
                    psum[me.second - k + 1 + 1]++;
                    psum[vec[j].second - k + 1 + 1]--;
                    psum[vec[j].first + 1]--;
                    psum[vec[j].first + x + 1]++;
                }
            }

            /*
            printf("%d / %d:\n", i, j);
            for (int k = 1; k <= 2*n; k++)
                printf("%d ", psum[k]);
            printf("\n");*/
        }

        // printf("%d : %d\n", i, now);
        ans = max(ans, now);

        int ss = 0;
        for (int j = i + 1; j <= n; j++) {
            // printf("%d / %d: %d %d\n", i, j, now, psum[j]);
            psum[j] += psum[j - 1];
            ss += psum[j];

            // printf("%d / %d: %d %d // %d\n", i, j, now, psum[j], ss);
            ans = max(ans, now + ss);
        }
    }

    printf("%d", ans);
}


// author: rdd6584
