#include<stdio.h>
#include<queue>
#include<algorithm>
using namespace std;
struct pnode{
int x,y,z;
}node, front;
int m, n, L , T, ans=0, matrix[1300][130][62];
bool inq[1300][130][62]={false};
int xx[6]={0,0,0,0,1,-1};
int yy[6]={0,0,1,-1,0,0};
int zz[6]={1,-1,0,0,0,0};
bool judge(int x, int y, int z){
if(x>=m||x<0||y>=n||y<0||z>=L||z<0)return false;
if(matrix[x][y][z]==0||inq[x][y][z]==true)return false;
if(matrix[x][y][z]==1&&inq[x][y][z]==false)return true;
else return true;
}
int BFS(int x, int y, int z){
int ii, newx, newy, newz, total=0;
queue<pnode> que;
node.x=x;node.y=y;node.z=z;
que.push(node);
inq[x][y][z]=true;
while(!que.empty()){
front=que.front();
que.pop();
total++;
for(ii=0;ii<6;ii++){
newx=front.x+xx[ii];
newy=front.y+yy[ii];
newz=front.z+zz[ii];
if(judge(newx,newy,newz)){
node.x=newx;node.y=newy;node.z=newz;
inq[newx][newy][newz]=true;
que.push(node);
}
}
}//while
if(total>=T)return total;
else return 0;
}
int main(){
int x, y, z;
scanf("%d%d%d%d",&m,&n,&L,&T);
for(z=0;z<L;z++)
for(x=0;x<m;x++)
for(y=0;y<n;y++)
scanf("%d",&matrix[x][y][z]);
for(z=0;z<L;z++)
for(x=0;x<m;x++)
for(y=0;y<n;y++){
if(matrix[x][y][z]==1&&inq[x][y][z]==false)
ans+=BFS(x,y,z);
}
printf("%d\n",ans);
return 0;
}