#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const ll NN = 2e5 + 5;
ll n, m, k, has;
ll a[2][2010][2010];
ll p1[2010][2010];
ll p2[2010][2010];
void upd(ll jen, ll kir, ll kan, ll idx, ll jum)
{
    // cout << jen << " " << kir << " " << kan << " " << idx << " " << jum << "\n"; 
    if(jen == 0)
    {
        if(kir > n)
            return ;
        p1[idx][kir] += jum;
        p1[idx][kan + 1] -= jum;
        // for(ll i = kir; i <= kan; i++)
        // {
        //     a[0][idx][i] += jum;
        // }
    }
    else
    {
        if(kan <= 0)
            return ;
        kan = min(kan, n - k + 1);
        p2[kan][idx] += jum;
        p2[kir - 1][idx] -= jum;
        // for(ll i = kir; i <= kan; i++)
        // {
        //     a[1][i][idx] += jum;
        // }
    }
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin >> n >> m >> k;
    for(ll i = 1; i <= m; i++)
    {
        ll ta, tb;
        cin >> ta >> tb;
        // cout << i << "___\n";
        for(ll j = 1; j <= n; j++)
        {
            ll kiri = j;
            ll kanan = j + k - 1;
            if(kiri < 1 || kanan > n)
                continue;
            // cout << kiri << " " << kanan << "\n";
            ll inter = min(tb, kanan) - max(ta, kiri) + 1;
            if(inter <= 0)continue; 
            if(kanan >= tb)
            {
                upd(0, kiri, n - k + 1, j, inter);
                continue;
            }
            if(ta <= kiri && kanan <= tb)
            {
                upd(0, kiri, n - k + 1, j, inter);
                continue;
            }
            upd(0, tb - inter + 1, n - k + 1, j, inter);
            // cout << j << "   " << tb - inter + 1 << " " << n - k + 1 << "\n";
            if(j < (tb - inter + 1))
                upd(0, j, j, j, inter);
        }
        for(ll j = 1; j <= n; j++)
        {
            ll kiri = j;
            ll kanan = j + k - 1;
            if(kiri < 1 || kanan > n)
                continue;
            ll inter = min(tb, kanan) - max(ta, kiri) + 1;
            if(inter <= 0)continue; 
            // cout << j << "   " << inter << ":   " << 1 << " " << ta + inter - 1 - k << "\n";
            upd(1, 1, ta + inter - 1 - k, j, inter);
        }
    }
    for(ll i = 1; (i + k - 1) <= n; i++)
    {
        ll hz = 0;
        for(ll j = 1; (j + k - 1) <= n; j++)
        {
            hz += p1[i][j];
            a[0][i][j] += hz;
        }
    }
    for(ll j = 1; (j + k - 1) <= n; j++)
    {
        ll hz = 0;
        for(ll i = (n - k + 1); i >= 1; i--)
        {
            hz += p2[i][j];
            a[1][i][j] += hz;
        }
    }
    for(ll i = 1; (i + k - 1) <= n; i++)
        for(ll j = 1; (j + k - 1) <= n; j++)
            has = max(has, a[0][i][j] + a[1][i][j]);
    // for(ll i = 1; (i + k - 1) <= n; i++)
    // {
    //     for(ll j = 1; (j + k - 1) <= n; j++)
    //     {
    //         // cout << i << " " << j << " " << a[0][i][j] << " " << a[1][i][j] << "\n";
    //         cout << a[0][i][j] << "+" << a[1][i][j] << "  ";
    //     }
    //     cout << "\n";
    // }
    cout << has << "\n";
}