#include <bits/stdc++.h>
using namespace std;
long n, k, ans, ar[200][200], s, m;
long v1, v2, t1, t2;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) cin >> ar[i][j];
  ans = k + 1;
  if (m <= 10) {
    for (int mask = 0; mask < (1 << m); mask++) {
      s = 0;
      for (int j = 0; j < m; j++) {
        if (ar[1][j + 1] > 0 && ((mask & (1 << j)) == 0)) ++s;
        if (ar[1][j + 1] == 0 && ((mask & (1 << j)) > 0)) ++s;
      }
      for (int i = 2; i <= n; i++) {
        t1 = t2 = 0;
        for (int j = 1; j <= m; j++) {
          v1 = (mask & (1 << (j - 1)));
          v2 = ar[i][j];
          if (v1 > 1) v1 = 1;
          if (v1 != v2)
            ++t1;
          else
            ++t2;
        }
        s += min(t1, t2);
      }
      ans = min(ans, s);
    }
  } else {
    for (int i = 1; i <= n; i++) {
      s = 0;
      for (int j = 1; j <= n; j++) {
        t1 = t2 = 0;
        for (int q = 1; q <= m; q++) {
          if (ar[j][q] != ar[i][q])
            ++t1;
          else
            ++t2;
        }
        s += min(t1, t2);
      }
      ans = min(ans, s);
    }
  }
  if (ans > k) ans = -1;
  cout << ans << endl;
  cin.get();
  cin.get();
  return 0;
}
