#include<iostream>
using namespace std;
int main() {
int arr[21][21][21] = {1};
int w, x, h, q;
int x1, y1, z1, x2, y2, z2;
cin >> w >> x >> h;
cin >> q;
for (int i = 0; i < q; i++)
{
cin >> x1 >> y1 >> z1 >> x2 >> y2 >> z2;
for(int j = x1;j<=x2;j++)
for(int k = y1;k<=y2;k++)
for (int g = z1; g <= z2; g++)
{
arr[j][k][g] = 0;
}
}
int cnt = 0;
for(int j = 1;j<=w;j++)
for(int k = 1;k<=x;k++)
for (int g = 1; g <= h; g++)
{
if (arr[j][k][g] == 1)
{
cnt++;
}
}
cout << cnt;
return 0;
}