#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
using namespace std;
int main()
{
int a[25][25][25];
int w, x, h;
int q;
cin >> w >> x >> h >> q;
int V = w * x * h;
int x1, y1, z1;
int x2, y2, z2;
int sum = 0;
while (q--) {
cin >> x1 >> y1 >> z1 >> x2 >> y2 >> z2;
for (int i = 1; i < w; i++)
for (int j = 1; j < x; j++)
for (int g = 1; g < h; g++)
a[i][j][g] = 1;
for (int i = x1; i <= x2; i++)
for (int j = y1; j <= y2; j++)
for (int g = z1; g <= z2; g++)
if (a[i][j][g] == 1) {
a[i][j][g] = 0;
sum++;
}
}
cout << V - sum;
return 0;
}