#include <bits/stdc++.h>
using namespace std;
int a[62][1300][1300];
struct node
{
int z, x, y;
};
int d[6][3] = {{0, -1, 0}, {0, 0, 1}, {0, 1, 0}, {0, 0, -1}, {1, 0, 0}, {-1, 0, 0}};
int n, m, L, T;
int sum;
void bfs(int z, int x, int y)
{
a[z][x][y] = 0;
int res = 1;
queue<node> que;
que.push({z, x, y});
while (que.size())
{
auto t = que.front();
que.pop();
for (int i = 0; i < 6; i++)
{
int rz = t.z + d[i][0], rx = t.x + d[i][1], ry = t.y + d[i][2];
if (rz < 0 || rz >= L || rx < 0 || rx >= n || ry < 0 || ry >= m || !a[rz][rx][ry])
continue;
a[rz][rx][ry] = 0;
res++;
que.push({rz, rx, ry});
}
}
if(res >= T) sum += res;
}
int main()
{
cin >> n >> m >> L >> T;
for (int z = 0; z < L; z++)
for (int x = 0; x < n; x++)
for (int y = 0; y < m; y++)
scanf("%d", &a[z][x][y]);
for (int z = 0; z < L; z++)
for (int x = 0; x < n; x++)
for (int y = 0; y < m; y++)
if (a[z][x][y]) bfs(z, x, y);
cout << sum << endl;
return 0;
}