#include <fstream>
#include <vector>
#include <algorithm>

using namespace std;

ifstream input("B_LINE.inp");
ofstream output("B_LINE.out");

int main()
{
	int m, n, k;
	int total = 0;
	input >> m >> n >> k;
	int size = m * n;
	vector <int> a(size);
	for (int i = 0; i < size; i++)
	{
		input >> a[i];
	}
	sort(a.begin(), a.end());
	int b = a[0];
	for (int i = 0; i < size; i++)
	{
		if (a[i] != b)
		{
			k--;
			b = a[i];
		}
		if (k == 0) break;
		total++;
	}
	output << total;
	input.close();
	output.close();
	return 0;
}