#include <stdio.h>
#define maxn 120
int a[maxn][maxn], m, n, t;
int check(int *i, int *j){
int k, cnt_r, cnt_c;
cnt_r = 0;
for(k = *i + 1; k < m; k++){
if(a[*i][*j] == a[k][*j]) cnt_r++;
if(cnt_r >= t){
*i = k;
return 1;
}
}
cnt_c = 0;
for(k = *j + 1; k < n; k++){
if(a[*i][*j] == a[*i][k]) cnt_c++;
if(cnt_c >= t){
*j = k;
return 1;
}
}
return 0;
}
int lastSq(int r, int c){
return (r == n - 1 && c == n);
}
int main(){
int res = 0, i, j, pos_r = 0, pos_c = 0;
scanf("%d%d%d", &m, &n, &t);
for(i = 0; i < m; i++)
for(j = 0; j < n; j++)
scanf("%d", &a[i][j]);
while(!lastSq(pos_r, pos_c)){
if(a[pos_r][pos_c] == 0){
if(pos_c < n - 1) pos_c++;
else if(pos_r < n - 1){
pos_c = 0;
pos_r++;
}
}
if(!check(&pos_r, &pos_c)){
res++;
if(pos_c < n - 1) pos_c++;
else{
pos_c = 0;
pos_r++;
}
}
}
printf("%d", res);
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgojZGVmaW5lIG1heG4gMTIwCgppbnQgYVttYXhuXVttYXhuXSwgbSwgbiwgdDsKCmludCBjaGVjayhpbnQgKmksIGludCAqail7CiAgICBpbnQgaywgY250X3IsIGNudF9jOwogICAgY250X3IgPSAwOwogICAgZm9yKGsgPSAqaSArIDE7IGsgPCBtOyBrKyspewogICAgICAgIGlmKGFbKmldWypqXSA9PSBhW2tdWypqXSkgY250X3IrKzsKICAgICAgICBpZihjbnRfciA+PSB0KXsKICAgICAgICAgICAgKmkgPSBrOwogICAgICAgICAgICByZXR1cm4gMTsKICAgICAgICB9CiAgICB9CiAgICBjbnRfYyA9IDA7CiAgICBmb3IoayA9ICpqICsgMTsgayA8IG47IGsrKyl7CiAgICAgICAgaWYoYVsqaV1bKmpdID09IGFbKmldW2tdKSBjbnRfYysrOwogICAgICAgIGlmKGNudF9jID49IHQpewogICAgICAgICAgICAqaiA9IGs7CiAgICAgICAgICAgIHJldHVybiAxOwogICAgICAgIH0KICAgIH0KICAgIHJldHVybiAwOwp9CgppbnQgbGFzdFNxKGludCByLCBpbnQgYyl7CiAgICByZXR1cm4gKHIgPT0gbiAtIDEgJiYgYyA9PSBuKTsKfQoKaW50IG1haW4oKXsKICAgIGludCByZXMgPSAwLCBpLCBqLCBwb3NfciA9IDAsIHBvc19jID0gMDsKICAgIHNjYW5mKCIlZCVkJWQiLCAmbSwgJm4sICZ0KTsKICAgIGZvcihpID0gMDsgaSA8IG07IGkrKykKICAgICAgICBmb3IoaiA9IDA7IGogPCBuOyBqKyspCiAgICAgICAgICAgIHNjYW5mKCIlZCIsICZhW2ldW2pdKTsKCiAgICB3aGlsZSghbGFzdFNxKHBvc19yLCBwb3NfYykpewogICAgICAgIGlmKGFbcG9zX3JdW3Bvc19jXSA9PSAwKXsKICAgICAgICAgICAgaWYocG9zX2MgPCBuIC0gMSkgcG9zX2MrKzsKICAgICAgICAgICAgZWxzZSBpZihwb3NfciA8IG4gLSAxKXsKICAgICAgICAgICAgICAgIHBvc19jID0gMDsKICAgICAgICAgICAgICAgIHBvc19yKys7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYoIWNoZWNrKCZwb3NfciwgJnBvc19jKSl7CiAgICAgICAgICAgIHJlcysrOwogICAgICAgICAgICBpZihwb3NfYyA8IG4gLSAxKSBwb3NfYysrOwogICAgICAgICAgICBlbHNlewogICAgICAgICAgICAgICAgcG9zX2MgPSAwOwogICAgICAgICAgICAgICAgcG9zX3IrKzsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KCiAgICBwcmludGYoIiVkIiwgcmVzKTsKfQ==