#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int a[110][110];
bitset<110> b[110];
bitset<110> td;
int pd[110][110][2][12];
int mark[110][110][2][12], passo;
void print(bitset<110> &msk, int j) {
  printf("> ");
  for (int i = 0; i < j; i++) printf("%d", (int)msk[i]);
  puts("");
}
int go(int i, int j, bool c, int q) {
  int &r = pd[i][j][c][q];
  if (mark[i][j][c][q] == passo) return r;
  r = -1;
  mark[i][j][c][q] = passo;
  if (i >= n) return r = q;
  bitset<110> x = b[0] & td;
  if (c) x.flip();
  int err = (x ^ (b[i] & td)).count();
  if (err <= q) {
    r = max(r, go(i + 1, j, c, q - err));
  }
  x = (x.flip() & td);
  err = (x ^ (b[i] & td)).count();
  if (err <= q) {
    r = max(r, go(i + 1, j, c, q - err));
  }
  return r;
}
int res;
void bt(int j, int q) {
  if (j > 0) {
    passo++;
    int tmp = go(1, j, 0, q);
    if (tmp == -1) return;
    if (j >= m) {
      res = min(res, k - tmp);
      return;
    }
  }
  td.set(j);
  bt(j + 1, q);
  b[0].flip(j);
  bt(j + 1, q - 1);
  b[0].flip(j);
  td.reset(j);
}
int main() {
  memset(mark, 0, sizeof(mark));
  passo = 0;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < n; i++) {
    b[i].reset();
    for (int j = 0; j < m; j++) scanf("%d", &a[i][j]), b[i][j] = a[i][j];
  }
  td.reset();
  res = 100;
  bt(0, k);
  if (res > k)
    puts("-1");
  else
    printf("%d\n", res);
}
