#include<iostream>
#include<queue>
using namespace std;
int M,N,L,T;
int v[1300][130][70];
bool vis[1300][130][70]={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};
struct node{
int x,y,z;
}t;
bool judge(node t){
if(t.x>=M||t.x<0||t.y>=N||t.y<0||t.z>=L||t.z<0) return false;
if(vis[t.x][t.y][t.z]==true||v[t.x][t.y][t.z]==0) return false;
return true;
}
int bfs(int x,int y,int z){
int total=0;
queue<node> q;
t.x=x;t.y=y;t.z=z;
q.push(t);
vis[x][y][z]=true;
while(!q.empty()){
node top=q.front();
q.pop();
total++;
for(int i=0;i<6;i++){
t.x=top.x+X[i];
t.y=top.y+Y[i];
t.z=top.z+Z[i];
if(judge(t)==true){
q.push(t);
vis[t.x][t.y][t.z]=true;
}
}
}
if(total>=T) return total;
else return 0;
}
int main(){
int sum=0;
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",&v[i][j][k]);
}
}
for(int k=0;k<L;k++){
for(int i=0;i<M;i++){
for(int j=0;j<N;j++){
if(vis[i][j][k]==false&&v[i][j][k]==1){
sum+=bfs(i,j,k);
}
}
}
}
printf("%d",sum);
return 0;
}