#include <iostream>
#include <math.h>
#include <iomanip>
#include <bits/stdc++.h>
#include <string.h>
#include <string>
#include <algorithm>
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof(a))
#define debug(x) cout << (#x) << " = " << x << endl;
#define debug2(i,j) cout << (#i) << "=" << i << " , " << (#j) << "=" << j << endl;

using namespace std;

ll binomialCoeff(ll n,ll k)
{
    ll res = 1;
    if(k >n - k)
        k = n - k;
    for(int i = 0; i < k; ++i)
    {
        res *= (n - i);
        res /= (i + 1);
    }
    return res;
}

ll mod0 = 1e9 + 7;

ll power(ll x,ll y)
{
    ll temp;
    if(y == 0)
        return 1;
    temp = power(x, y/2);
    if (y%2 == 0)
        return (temp*temp) % mod0;
    else
        return (((x*temp)%mod0)*temp)%mod0;
}


/* nCr % mod
const int N0 = 1e5 + 5;
ll fact[6*N0];
ll inv[6*N0],invfac[6*N0];
ll mod = 1e9 + 7;

void factorial()
{
    fact[0] = invfac[0] = fact[1] = invfac[1] = 1;
    inv[1] = 1;
    for(int i=2;i<=5*N0 + 10;i++)
    {
        fact[i] = (fact[i-1]*i)%mod;
        inv[i] = (inv[mod%i]*(mod - mod/i))%mod;
        invfac[i] = (invfac[i-1]*inv[i])%mod;
    }
}*/

vector<ll> primes;
vector<bool> prime;

void Sieve(int n)
{
    prime = vector<bool> (n+1,true);
    //vector<bool> prime(n+1,true);
    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
          primes.push_back(p);
}

ll modInverse(ll a,ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
    if (m == 1)
      return 0;
    while (a > 1)
    {
        ll q = a / m;
        ll t = m;
        m = a % m, a = t;
        t = y;
        y = x - q * y;
        x = t;
    }
    if (x < 0)
       x += m0;
    return x;
}

//******************************************************    CHECK CONSTRAINTS   ***************************************************************//

const int Nmax = 2e5 + 6;
const int N = 4005;

ll tree[4*N];
ll lazy[4*N];

void build(int node,int start,int end)
{
    if(start == end)
    {
        tree[node] = 0;
        lazy[node] = 0;
        return;
    }
    lazy[node] = 0;
    tree[node] = 0;
    int mid = (start + end)/2;
    build(2*node,start,mid);
    build(2*node + 1,mid+1,end);
}

void update(int node,int start,int end,int l,int r,int val)
{
    if(lazy[node])
    {
        tree[node] += lazy[node]*(end - start + 1);
        if(start != end)
        {
            lazy[2*node] += lazy[node];
            lazy[2*node + 1] += lazy[node];
        }
        lazy[node] = 0;
    }
    if(r < start || end < l || start > end)
        return;
    if(start >= l && end <= r)
    {
        tree[node] += (end - start + 1)*val;
        if(start!=end)
        {
            lazy[2*node] += val;
            lazy[2*node+1] += val;
        }
        return;
    }
    int mid = (start + end)/2;
    update(2*node,start,mid,l,r,val);
    update(2*node+1,mid+1,end,l,r,val);
    tree[node] = tree[2*node + 1] + tree[2*node];
}

ll get(int node,int start,int end,int l,int r)
{
    if(lazy[node])
    {
        tree[node] += lazy[node]*(end - start + 1);
        if(start != end)
        {
            lazy[2*node] += lazy[node];
            lazy[2*node + 1] += lazy[node];
        }
        lazy[node] = 0;
    }
    if(start > end || end < l || start > r)
        return 0;
    if(start >= l && end <= r)
        return tree[node];
    int mid = (start + end)/2;
    ll a = get(2*node,start,mid,l,r);
    ll b = get(2*node+1,mid+1,end,l,r);
    return (a + b);
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,m,k;
    cin >> n >> m >> k;
    build(1,1,N);
    vector<pair<int,int>> v(m);
    for(int i=0;i<m;i++)
        cin >> v[i].first >> v[i].second ;
    sort(v.begin(),v.end());
    ll ans = 0;
    for(int i=1;i<=n-k+1;i++)
    {
        ll val = 0;
        ll r1 = 0;
        ll r2 = 0;
        build(1,1,N);
        vector<pair<pair<int,int> , pair<int,int>>> z[N];
        for(auto x : v)
        {
            int l = x.first;
            int r = x.second;
            if(r < i)
                continue;
            if(l > i+k-1)
            {
                update(1,1,N,l,r,1);
                continue;
            }
            /*if(l <= i)
            {
                int a = min(r,i+k-1) - max(i,l) + 1;
                z[i].push_back({{i,a},{l,r}});
                r1 += a;
                continue;
            }*/
            int a = min(r,i+k-1) - max(i,l) + 1;
            r1 += a;
            int b = r - a + 1;
            z[b].push_back({{b,a},{l,r}});
        }
        for(int j=n+1;j>=i;j--)
        {
            for(auto x : z[j])
            {
                int l = x.second.first;
                int r = x.second.second;
                r1 -= x.first.second;
                update(1,1,N,l,r,1);
            }
            r2 = get(1,1,N,j,j+k-1);
            val = max(val,r1+r2);
        }
        ans = max(ans,val);
    }
    cout << ans;
}
