#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
int n, m, k, a[100][100];
bool solve() {
  if (scanf("%d%d%d", &n, &m, &k) == EOF) return false;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) scanf("%d", &a[i][j]);
  }
  int ans = inf;
  if (n <= k) {
    for (int mask = 0; mask < (1 << n); ++mask) {
      int x[100], tans = 0;
      for (int i = 0; i < n; ++i) x[i] = (mask & (1 << i)) != 0;
      for (int j = 0; j < m; ++j) {
        int cnt = 0;
        for (int i = 0; i < n; ++i) cnt += a[i][j] ^ x[i];
        tans += min(cnt, n - cnt);
      }
      ans = min(ans, tans);
    }
  } else {
    for (int fi = 0; fi < n; ++fi) {
      int tans = 0;
      for (int i = 0; i < n; ++i) {
        int cnt = 0;
        for (int j = 0; j < m; ++j) cnt += a[i][j] ^ a[fi][j];
        tans += min(cnt, m - cnt);
      }
      ans = min(ans, tans);
    }
  }
  printf("%d\n", ans > k ? -1 : ans);
  return true;
}
int main() {
  solve();
  return 0;
}
