#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
int main() {
  ios_base::sync_with_stdio(0);
  int n, m, k;
  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];
  int odp = INF;
  if (n > k) {
    for (int i = 0; i < n; ++i) {
      int il = 0;
      for (int j = 0; j < n; ++j) {
        int c = 0;
        for (int l = 0; l < m; ++l)
          if (a[j][l] != a[i][l]) ++c;
        il += min(c, m - c);
      }
      if (il <= k) odp = min(odp, il);
    }
  } else {
    for (int i = 0; i < (1 << n); ++i) {
      int il = __builtin_popcount(i);
      vector<int> x(n);
      for (int j = 0; j < n; ++j) x[j] = a[j][0];
      for (int j = 0; j < n; ++j)
        if ((i & (1 << j)) > 0) x[j] ^= 1;
      for (int l = 1; l < m; ++l) {
        int c = 0;
        for (int j = 0; j < n; ++j)
          if (a[j][l] != x[j]) ++c;
        il += min(c, n - c);
      }
      if (il <= k) odp = min(odp, il);
    }
  }
  if (odp == INF) odp = -1;
  cout << odp;
  return 0;
}
