#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, k, res = 999999;
  cin >> n >> m >> k;
  vector<vector<int> > a(n, vector<int>(m));
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> a[i][j];
  if (n > k) {
    for (int i = 0; i < n; i++) {
      int cnt = 0;
      for (int j = 0; j < n; j++) {
        int cntt = 0;
        for (int c = 0; c < m; c++)
          if (a[i][c] == a[j][c]) cntt++;
        cnt += ((cntt < m - cntt) ? cntt : m - cntt);
      }
      res = ((res < cnt) ? res : cnt);
    }
  } else {
    for (int c = 0; c < (1 << n); c++) {
      int cnt = 0;
      for (int i = 0; i < m; i++) {
        int cntt = 0;
        for (int j = 0; j < n; j++)
          if (a[j][i] == (c >> j & 1)) cntt++;
        cnt += ((cntt < n - cntt) ? cntt : n - cntt);
      }
      res = ((res < cnt) ? res : cnt);
    }
  }
  if (res > k)
    cout << -1 << endl;
  else
    cout << res << endl;
  return 0;
}
