#include <cstdio>
#include <queue>
using namespace std;
struct Node{
int x;
int y;
int z;
}tmp;
int M, N, L, T;
int data[1290][130][61];
bool stat[1290][130][61] = {false};
int X[6] = {1, -1, 0, 0, 0, 0};
int Y[6] = {0, 0, 1, -1, 0, 0};
int Z[6] = {0, 0, 0, 0, 1, -1};
bool isNewIsOne(int x, int y, int z){
if(x >= M || y >= N || z >= L || x < 0 || y < 0 || z < 0)
return false;
if(data[x][y][z] == 0 || stat[x][y][z] == true)
return false;
return true;
}
int BFS(int x, int y, int z){
int count = 0;
queue<Node> q;
tmp.x = x;
tmp.y = y;
tmp.z = z;
q.push(tmp);
stat[x][y][z] = true;
while (q.size() != 0) {
Node n = q.front();
q.pop();
count++;
for(int i = 0; i < 6; i++){
int newx = n.x + X[i];
int newy = n.y + Y[i];
int newz = n.z + Z[i];
if(isNewIsOne(newx, newy, newz)){
tmp.x = newx;
tmp.y = newy;
tmp.z = newz;
q.push(tmp);
stat[newx][newy][newz] = true;
}
}
}
return (count >= T) ? count : 0;
}
int main(){
scanf("%d %d %d %d", &M, &N, &L, &T);
int i, j, k, count = 0;
for(k = 0; k < L; k++)
for(i = 0; i < M; i++)
for(j = 0; j < N; j++)
scanf("%d", &data[i][j][k]);
for(k = 0; k < L; k++){
for(k = 0; k < L; k++)for(i = 0; i < M; i++){
for(j = 0; j < N; j++){
if(data[i][j][k] == 1 && stat[i][j][k] == false){
count += BFS(i, j, k);
}
}
}
}
printf("%d", count);
return 0;
}