#include <bits/stdc++.h>
int g[100][100];
int n, m, lim;
void work1() {
  int ans = 0x7fffffff;
  for (int i = 0; i < n; i++) {
    int sum = 0;
    for (int j = 0; j < n; j++) {
      int cnt = 0;
      for (int k = 0; k < m; k++) {
        if (g[i][k] == g[j][k]) cnt++;
      }
      sum += std::min(cnt, m - cnt);
    }
    ans = std::min(ans, sum);
  }
  if (ans > lim) ans = -1;
  printf("%d\n", ans);
}
int line[100];
void work2() {
  int ans = 0x7fffffff;
  for (int sta = 0; sta < 1 << n; sta++) {
    int sum = 0;
    for (int i = 0; i < n; i++) line[i] = 1 & (sta >> i);
    for (int j = 0; j < m; j++) {
      int cnt = 0;
      for (int i = 0; i < n; i++) {
        if (g[i][j] == line[i]) cnt++;
      }
      sum += std::min(cnt, n - cnt);
    }
    ans = std::min(ans, sum);
  }
  if (ans > lim) ans = -1;
  printf("%d\n", ans);
}
int main() {
  while (scanf("%d%d%d", &n, &m, &lim) == 3) {
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++) scanf("%d", &g[i][j]);
    if (n > lim)
      work1();
    else
      work2();
  }
  return 0;
}
