- #include <algorithm> 
- #include <array> 
- #include <bitset> 
- #include <cassert> 
- #include <chrono> 
- #include <cmath> 
- #include <cstring> 
- #include <functional> 
- #include <iomanip> 
- #include <iostream> 
- #include <limits> 
- #include <map> 
- #include <numeric> 
- #include <queue> 
- #include <random> 
- #include <set> 
- #include <vector> 
- using namespace std; 
-   
- template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; } 
- template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }  
- void dbg_out() { cout << endl; } 
- template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cout << ' ' << H; dbg_out(T...); } 
-   
- #ifdef imtiyazrasool92 
- #define dbg(...) cout << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__) 
- #else 
- #define dbg(...) 
- #endif 
-   
- const int nax = 200; 
-   
- void run_case(){ 
-     int N,K; 
-     cin >> N >> K; 
-     vector<vector<int>> A(nax,vector<int> (nax)); 
-     int curr = 0; 
-     for(int i = 0,x1,x2,y1,y2;i < N;i++){ 
-         cin >> x1 >> y1 >> x2 >> y2; 
-         A[x1][y1]++; 
-         if(y2 < nax) 
-             A[x1][y2]--; 
-         if(x2 < nax) 
-             A[x2][y1]--; 
-         if(x2 < nax && y2 < nax) 
-             A[x2][y2]++; 
-     } 
-     vector<vector<int>> actual(nax,vector<int> (nax)); 
-     for(int i = 0;i < nax;i++){ 
-         for(int j = 0;j < nax;j++){ 
-             if(j > 0){ 
-                 A[i][j] += A[i][j - 1]; 
-             } 
-             if(i > 0){ 
-                 A[i][j] += A[i - 1][j]; 
-             } 
-             if(i > 0 && j > 0){ 
-                 A[i][j] -= A[i - 1][j - 1]; 
-             } 
-             if(A[i][j] == K){ 
-                 actual[i][j] = -1; 
-                 curr++; 
-             } 
-             if(A[i][j] == K - 1) 
-                 actual[i][j] = 1; 
-         } 
-     } 
-     vector<vector<int>> leftup,rightup,leftdown,rightdown; 
-     leftup = rightup = leftdown = rightdown = actual; 
-     for(int i = 0;i < nax;i++){ 
-         for(int j = 1;j < nax;j++){ 
-             leftup[i][j] += leftup[i][j - 1]; 
-             leftdown[i][j] += leftdown[i][j - 1]; 
-         } 
-     } 
-     for(int i = nax - 1;i>=0;i--){ 
-         for(int j = nax - 2;j>=0;j--){ 
-             rightup[i][j] += rightup[i][j + 1]; 
-             rightdown[i][j] += rightdown[i][j + 1]; 
-         }    
-     } 
-     for(int i = 1;i < nax;i++){ 
-         for(int j = 0;j < nax;j++){ 
-             leftup[i][j] += leftup[i - 1][j]; 
-             rightup[i][j] += rightup[i - 1][j]; 
-         } 
-     } 
-     for(int i = nax - 2;i>=0;i--){ 
-         for(int j = 0;j < nax;j++){ 
-             leftdown[i][j] += leftdown[i + 1][j]; 
-             rightdown[i][j] += rightdown[i + 1][j]; 
-         }    
-     } 
-     // max 
-     for(int i = 0;i < nax;i++){ 
-         for(int j = 1;j < nax;j++){ 
-             leftup[i][j] = max(leftup[i][j - 1],leftup[i][j]); 
-             leftdown[i][j] = max(leftdown[i][j],leftdown[i][j - 1]); 
-         } 
-     } 
-     for(int i = nax - 1;i>=0;i--){ 
-         for(int j = nax - 2;j>=0;j--){ 
-             rightup[i][j] = max(rightup[i][j + 1],rightup[i][j]); 
-             rightdown[i][j] = max(rightdown[i][j + 1],rightdown[i][j]); 
-         }    
-     } 
-     for(int i = 1;i < nax;i++){ 
-         for(int j = 0;j < nax;j++){ 
-             leftup[i][j] = max(leftup[i][j],leftup[i - 1][j]); 
-             rightup[i][j] = max(rightup[i][j],rightup[i - 1][j]); 
-         } 
-     } 
-     for(int i = nax - 2;i>=0;i--){ 
-         for(int j = 0;j < nax;j++){ 
-             leftdown[i][j] = max(leftdown[i][j],leftdown[i + 1][j]); 
-             rightdown[i][j] = max(rightdown[i][j],rightdown[i + 1][j]); 
-         }    
-     } 
-     auto max_of = [](vector<int> Y){ 
-         sort(Y.rbegin(),Y.rend()); 
-         return Y[0] + Y[1]; 
-     }; 
-     int answer = 0; 
-     for(int i = 0;i < nax + 1;i++){ 
-         for(int j = 0;j < nax + 1;j++){ 
-             int a = 0,b = 0,c = 0,d = 0; 
-             if(i && j){ 
-                 a = max(a,leftup[i - 1][j - 1]); 
-             } 
-             if(i && j < nax){ 
-                 b = max(b,rightup[i - 1][j]); 
-             } 
-             if(i < nax && j < nax){ 
-                 c = max(c,rightdown[i][j]); 
-             } 
-             if(i < nax && j){ 
-                 d = max(d,leftdown[i][j - 1]); 
-             } 
-             answer = max(answer,max_of({a,b,c,d})); 
-         } 
-     } 
-     cout << answer + curr; 
- } 
-   
- int main(){ 
-     cin.tie(0)->sync_with_stdio(0); 
-     // freopen("paintbarn.in","r",stdin); 
-     // freopen("paintbarn.out","w",stdout); 
-     int tests = 1; 
-     // cin >> tests; 
-     while(tests--){ 
-         run_case(); 
-         cout << '\n'; 
-     } 
- }