#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <queue>
using namespace std;
struct Node{
int x, y, z;
};
int M, N, L, T;
int regin[1300][130][65];
int nextx[] = {-1, 1, 0, 0, 0, 0};
int nexty[] = {0, 0, -1, 1, 0, 0};
int nextz[] = {0, 0, 0, 0, -1, 1};
int legal(int x, int y, int z){
return x >= 0 && x < M &&
y >= 0 && y < N &&
z >= 0 && z < L;
}
int bfs(int x, int y, int z){
int con = 1;
regin[x][y][z] = 0;
Node next;
next.x = x; next.y = y; next.z = z;
queue<Node> q;
q.push(next);
while(!q.empty()){
Node temp = q.front();
q.pop();
int x1, y1, z1;
for(int i = 0; i < 6; i++){
x1 = temp.x + nextx[i];
y1 = temp.y + nexty[i];
z1 = temp.z + nextz[i];
if(legal(x1, y1, z1) && regin[x1][y1][z1] == 1){
regin[x1][y1][z1] = 0;
con++;
next.x = x1; next.y = y1; next.z = z1;
q.push(next);
}
}
}
return con;
}
int main(){
scanf("%d %d %d %d", &M, &N, &L, &T);
for(int k = 0; k < L; k++){
for(int i = 0; i < M; i++){
for(int j = 0; j < N; j++){
scanf("%d", ®in[i][j][k]);
}
}
}
int ans = 0, con;
for(int k = 0; k < L; k++){
for(int i = 0; i < M; i++){
for(int j = 0; j < N; j++){
if(regin[i][j][k] == 1){
con = bfs(i, j, k);
ans += (con >= T ? con : 0);
}
}
}
}
printf("%d\n", ans);
return 0;
}