#include <bits/stdc++.h>
#define mk make_pair
#define pb push_back
#define ms(x, y) memset(x, y, sizeof(x))
typedef long long ll;

using namespace std;
vector<pair<int, int>> a;
int cmp(pair<int, int> x, pair<int, int> y) {
    return (x.first + x.second) < (y.first + y.second);
}
int intersect(int x1, int y1, int x2, int y2) {
    if (x1 > x2) swap(x1, x2), swap(y1, y2);
    return max(0, min(y1, y2) - x2 + 1);
}
int b[2003][2003];
int n, m, k;
int solve(int x) {
    int l = 1, r = m, mid;
    while (l != r) {
        mid = r - (r - l >> 1);
        if (a[mid - 1].first + a[mid - 1].second <= x)
            l = mid;
        else
            r = mid - 1;
    }
    return l;
}
int main() {
    ios::sync_with_stdio(0);
    cin >> n >> m >> k;
    for (int i = 1; i <= m; i++) {
        int l, r;
        cin >> l >> r;
        a.pb(mk(l, r));
    }
    sort(a.begin(), a.end(), cmp);
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j < a.size(); j++) {
            if (j) b[i][j + 1] = b[i][j];
            b[i][j + 1] += intersect(i, i + k - 1, a[j].first, a[j].second);
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = i; j <= n; j++) {
            int t = solve(i + j + k - 1);
            ans = max(ans, b[i][t] + b[j][m] - b[j][t]);
        }
    }
    cout << ans;
    return 0;
}