import numpy as np

input_str = raw_input()
N, K = [int(x) for x in input_str.split(' ')]
input_lines = []
for n in range(N):
    input_str = raw_input()
    input_lines.append(input_str)
x_grid = set()
y_grid = set()
d_grid = set()
for line in input_lines:
    x1, y1, d1, x2, y2, d2 = [int(x) for x in line.split(' ')]
    x_grid.add(x1)
    x_grid.add(x2)
    y_grid.add(y1)
    y_grid.add(y2)
    d_grid.add(d1)
    d_grid.add(d2)

x_grid = sorted(x_grid)
y_grid = sorted(y_grid)
d_grid = sorted(d_grid)
x_grid_index = {x[1]:x[0] for x in enumerate(x_grid)}
y_grid_index = {y[1]:y[0] for y in enumerate(y_grid)}
d_grid_index = {d[1]:d[0] for d in enumerate(d_grid)}

fish_dist = np.zeros( (len(x_grid), len(y_grid), len(d_grid)), dtype=int )

for line in input_lines:
    x1, y1, d1, x2, y2, d2 = [int(x) for x in line.split(' ')]
    x1_index = x_grid_index[x1]
    x2_index = x_grid_index[x2]
    y1_index = y_grid_index[y1]
    y2_index = y_grid_index[y2]
    d1_index = d_grid_index[d1]
    d2_index = d_grid_index[d2]
    fish_dist[x1_index:x2_index, y1_index:y2_index, d1_index:d2_index] += 1

volume = 0
for (x_index, y_index, d_index), num in np.ndenumerate(fish_dist):
    if num >= K:
        x_begin = x_grid[x_index]
        y_begin = y_grid[y_index]
        d_begin = d_grid[d_index]
        x_end = x_grid[x_index + 1]
        y_end = y_grid[y_index + 1]
        d_end = d_grid[d_index + 1]
        volume += (x_end - x_begin) * (y_end - y_begin) * (d_end - d_begin)
print(volume)

### FIXED CODE ###

import itertools

def main():
    input_lines = []
    input_lines.append(input())
    N, K = [int(x) for x in input_lines[0].split(' ')]
    for i in range(N):
        input_lines.append(input())

    grid = [set() for i in range(3)]
    data = []
    for line in input_lines[1:]:
        x1, y1, d1, x2, y2, d2 = [int(x) for x in line.split(' ')]
        data.append((x1, y1, d1, x2, y2, d2))
        grid[0].add(x1)
        grid[0].add(x2)
        grid[1].add(y1)
        grid[1].add(y2)
        grid[2].add(d1)
        grid[2].add(d2)

    grid = [sorted(g) for g in grid]
    grid_index = [{x[1]:x[0] for x in enumerate(g)} for g in grid]
    grid_len = [len(g) for g in grid]

    fish_dist = [[[0 for i in range(grid_len[2])] for i in range(grid_len[1])] for i in range(grid_len[0])]

    for x1, y1, d1, x2, y2, d2 in data:
        x1_index = grid_index[0][x1]
        x2_index = grid_index[0][x2]
        y1_index = grid_index[1][y1]
        y2_index = grid_index[1][y2]
        d1_index = grid_index[2][d1]
        d2_index = grid_index[2][d2]
        for x_index, y_index, d_index in itertools.product( range(x1_index, x2_index), range(y1_index, y2_index), range(d1_index, d2_index) ):
            fish_dist[x_index][y_index][d_index] += 1

    volume = 0
    for x_index, y_index, d_index in itertools.product(range(grid_len[0]), range(grid_len[1]), range(grid_len[2])):
        if fish_dist[x_index][y_index][d_index] >= K:
            x_begin = grid[0][x_index]
            y_begin = grid[1][y_index]
            d_begin = grid[2][d_index]
            x_end = grid[0][x_index + 1]
            y_end = grid[1][y_index + 1]
            d_end = grid[2][d_index + 1]
            volume += (x_end - x_begin) * (y_end - y_begin) * (d_end - d_begin)
    print(volume)

main()