#include <bits/stdc++.h>   using namespace std;   #define FOR(i, n) for (int (i) = 0; (i) < (n); (i)++)   #define FORI(i, a, b) for (int (i) = (a); (i) < (b); (i)++)       #define ll long long   #define mp(m, n) make_pair((m), (n))   // #define DEBUG       #ifdef DEBUG   template<typename T>   void _debug(string s, T x) {       cerr << s <<  : ;       for (auto it = x.begin(); it != x.end(); ++it) {           cerr <<     << *it;       }       cerr << endl;   }       template<typename T, typename K>   void _debug(string s, map<T, K> x) {       cerr << s <<  : ;       for (auto it = x.begin(); it != x.end(); ++it) {           cerr <<     << it->first <<  :  << it->second;       }       cerr << endl;   }      template<typename T, typename K>   void _debug(string s, set<T, K> x) {       cerr << s <<  : ;       for (auto it = x.begin(); it != x.end(); ++it) {           cerr <<     << *it;       }       cerr << endl;   }       template<typename T, typename K>   void _debug(string s, vector<pair<T, K> > x) {       cerr << s <<  : ;       for (auto it = x.begin(); it != x.end(); ++it) {           cerr <<     << it->first <<  ,  << it->second;       }       cerr << endl;   }      void _debug(string s, int x) {       cerr << s <<  :   << x << endl;   }   void _debug(string s, long long x) {       cerr << s <<  :   << x << endl;   }   void _debug(string s, double x) {       cerr << s <<  :   << x << endl;   }   #define debug(x) _debug(#x, (x))   #else   #define debug(x)   #endif       #define db debug      const long long N = 2e3 + 4;   int t[4*N] = {};      void add(int L, int R, int val, int index = 1, int l = 1, int r = N - 1) {              if (L > R) return;       if (r < L || l > R) return;       if (L <= l && r <= R) {t[index] += val; return; }       int mid = (l + r) / 2;       // debug(l);debug(r);debug(mid);       add(L, R, val, index * 2, l, mid);       add(L, R, val, index * 2 + 1, mid + 1, r);          // if (pos < l || pos > r) return;       // if (l == r) {       //     t[index] = val;       //     return;       // }       // int mid = (l + r) / 2;       // upd(pos, val, index * 2, l, mid);       // upd(pos, val, index * 2 + 1, mid + 1, r);       // t[index] = min(t[index * 2], t[index * 2 + 1]);   }      int get_val(int pos, int index = 1, int l = 1, int r = N - 1) {       if (pos < l || pos > r) return 0;       if (l == r) {           return t[index];       }       int mid = (l + r) / 2;       return t[index] + get_val(pos, index * 2, l, mid) + get_val(pos, index * 2 + 1, mid + 1, r);   }      inline int in(int a, int b, int c, int d) {       int x = max(a, c);       int y = min(b, d);       return max(0, y - x + 1);   }      int main() {       ios_base::sync_with_stdio(false); std::cin.tie(0);       int n, m, k;       cin >> n >> m >> k;       vector<int> l(m), r(m);       FOR(i, m) cin >> l[i] >> r[i];       int R = 0;       for (int i = 1; i + k - 1 <= n; i++) {           memset(t, 0, sizeof(t));           int ans = 0;           for (int j = 0; j < m; j++) {               ans += in(i, i + k - 1, l[j], r[j]);               int x, y;               x = max(i + 1, l[j] - k + 1);               y = l[j];               vector<int> vvv;               vvv = {x, y, 1};               debug(vvv);               add(x, y, 1);               // int xx = r[j] - k + 2;               // int yy = r[j] + 1;               // yy = min(yy, xx + y - x);               int xx = r[j] - k + 2;               int yy = r[j] + 1;               xx = max(i + 1, xx);               yy = min(yy, xx + y - x);                  add(xx, yy, -1);               vvv = {xx, yy, -1};               debug(vvv);           }           debug(i);           debug(ans);           R = max(R, ans);           for (int j = i + 1; j + k - 1 <= n; j++) {               ans += get_val(j);               R = max(R, ans);               debug(j); debug(ans);           }       }       cout << R << endl;   }