#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

template <class T>
std::map<T, int> compress(std::vector<T>& v) {
    std::sort(v.begin(), v.end());
    v.erase(std::unique(v.begin(), v.end()), v.end());

    std::map<T, int> rev;
    for (int i = 0; i < (int)v.size(); ++i) rev[v[i]] = i;
    return rev;
}

template <class T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }

using lint = long long;

struct Point {
    lint x, y, z;
};

void solve() {
    int n, m;
    std::cin >> n >> m;

    std::vector<lint> xs, ys, zs;
    std::vector<Point> lps(n), rps(n);
    for (int i = 0; i < n; ++i) {
        auto& lp = lps[i];
        auto& rp = rps[i];
        std::cin >>
            lp.x >> lp.y >> lp.z >>
            rp.x >> rp.y >> rp.z;

        xs.push_back(lp.x);
        xs.push_back(rp.x);
        ys.push_back(lp.y);
        ys.push_back(rp.y);
        zs.push_back(lp.z);
        zs.push_back(rp.z);
    }

    auto revx = compress(xs);
    auto revy = compress(ys);
    auto revz = compress(zs);
    int xn = xs.size(), yn = ys.size(), zn = zs.size();

    auto grid = vec(xn, vec(yn, vec(zn, 0)));
    for (int i = 0; i < n; ++i) {
        auto l = lps[i], r = rps[i];

        l.x = revx[l.x], r.x = revx[r.x];
        l.y = revy[l.y], r.y = revy[r.y];
        l.z = revz[l.z], r.z = revz[r.z];

        ++grid[l.x][l.y][l.z];

        --grid[r.x][l.y][l.z];
        --grid[l.x][r.y][l.z];
        --grid[l.x][l.y][r.z];

        ++grid[l.x][r.y][r.z];
        ++grid[r.x][l.y][r.z];
        ++grid[r.x][r.y][l.z];

        --grid[r.x][r.y][r.z];
    }

    for (int i = 0; i < xn; ++i) {
        for (int j = 0; j < yn; ++j) {
            for (int k = 0; k + 1 < zn; ++k) {
                grid[i][j][k + 1] += grid[i][j][k];
            }
        }
    }
    for (int i = 0; i < xn; ++i) {
        for (int j = 0; j + 1 < yn; ++j) {
            for (int k = 0; k < zn; ++k) {
                grid[i][j + 1][k] += grid[i][j][k];
            }
        }
    }
    for (int i = 0; i + 1 < xn; ++i) {
        for (int j = 0; j < yn; ++j) {
            for (int k = 0; k < zn; ++k) {
                grid[i + 1][j][k] += grid[i][j][k];
            }
        }
    }

    lint ans = 0;
    for (int i = 0; i < xn; ++i) {
        for (int j = 0; j < yn; ++j) {
            for (int k = 0; k < zn; ++k) {
                if (grid[i][j][k] < m) continue;
                ans += (xs[i + 1] - xs[i]) * (ys[j + 1] - ys[j]) * (zs[k + 1] - zs[k]);
            }
        }
    }

    std::cout << ans << "\n";
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}

