#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const int MAX = 200;
int a[MAX][MAX], b[MAX][MAX];
int m, n, k;
int ans;
void gao() {
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
        if (a[i][j] == a[i][k]) b[j][k]++;
      }
    }
  }
  ans = inf;
  for (int i = 0; i < n; i++) {
    int cnt = 0;
    for (int j = 0; j < n; j++) {
      cnt += ((b[i][j] > (m - b[i][j]) ? m - b[i][j] : b[i][j]));
    }
    if (cnt < ans) ans = cnt;
  }
  if (ans <= k)
    printf("%d\n", ans);
  else
    printf("-1\n");
}
int main() {
  scanf("%d %d %d", &m, &n, &k);
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) scanf("%d", &a[i][j]);
  }
  if (n <= 10) {
    ans = inf;
    for (int state = 0; state < (1 << n); ++state) {
      int tot = 0;
      for (int i = 0; i < m; ++i) {
        int cnt = 0;
        for (int j = 0; j < n; ++j) {
          if (a[i][j] == 0 && ((state & (1 << j)) == 0)) ++cnt;
          if (a[i][j] && (state & (1 << j))) ++cnt;
        }
        if (n - cnt < cnt)
          tot += n - cnt;
        else
          tot += cnt;
      }
      if (tot < ans) ans = tot;
    }
    if (ans <= k)
      printf("%d\n", ans);
    else
      printf("-1\n");
  } else
    gao();
  return 0;
}
