#include <bits/stdc++.h>
using namespace std;
long a[10000][10000];
long z[10000];
int main ()
{
	freopen ("B_LINE.inp", "r", stdin);
	freopen ("B_LINE.out", "w", stdout);
	long b,c,d=1,e=1,f=0,k,max=0;
	cin >> b >> c >> k;
	for (int i=1; i<=b; i++)
		for (int j=1; j<=c; j++)
		{
			cin>>a[i][j];
			z[a[i][j]]++;
			if (a[i][j]>max) max=a[i][j];
		}
	sort (z+1, z+max+1, greater<int>());
	for ( int i=1; i<=k; i++)
	if (z[i]!=0) f+=z[i];
	cout << f;
}
