int cnt=0; for(int i=1;i<=x;i++){ for(int j=1;j<=y;j++){ for(int k=1;k<=z;k++){ if(s[i][j][k]==0){ cnt++; } } } }