#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<queue>using namespace std;int cnt,temp;
int n,m,K;
int a[505][505];
int pre[505][505];//二维前缀和void sol()
{cin>>n>>m>>K;for(int i=1;i<=n;++i){for(int j=1;j<=m;++j){cin>>a[i][j];pre[i][j]=a[i][j]+pre[i-1][j]+pre[i][j-1]-pre[i-1][j-1];}}int limit;//等到第四层循环时,在k行l列时超过K,记录下其l值。当i,j不变,k为k+1行时,再次达到l时一定会再次超过K,所以进行剪枝for(int i=1;i<=n;++i){for(int j=1;j<=m;++j){limit=m;for(int k=i;k<=n;++k){for(int l=j;l<=m&&l<=limit;++l){temp=pre[k][l]-pre[i-1][l]-pre[k][j-1]+pre[i-1][j-1];if(temp<=K)++cnt;else {limit=l;break;}}}}}cout<<cnt<<endl;
}int main()
{ios::sync_with_stdio(false);cin.tie(0);sol();
}