#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int s = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = 0;
    c = getchar();
  }
  while (c >= '0' && c <= '9')
    s = (s << 1) + (s << 3) + (c ^ 48), c = getchar();
  return f ? s : -s;
}
const int N = 110, inf = 1e9 + 7;
int n, m, k, ans = inf;
bitset<N> a[N], p;
int main() {
  ans = inf;
  n = read();
  m = read();
  k = read();
  for (register int i = 0; i < n; ++i)
    for (register int j = 0; j < m; ++j) a[i][j] = read();
  if (n <= k) {
    for (register int S = 0; S < (1 << n); ++S) {
      int tmp = 0;
      for (register int i = 0; i < m; ++i) {
        int cnt = 0;
        for (register int j = 0; j < n; ++j) cnt += (a[j][i] != ((S >> j) & 1));
        tmp += min(cnt, n - cnt);
      }
      ans = min(ans, tmp);
    }
  } else {
    for (register int i = 0; i < n; ++i) {
      int tmp = 0;
      for (register int j = 0; j < n; ++j) {
        if (j != i) p = a[i] ^ a[j];
        tmp += min(p.count(), m - p.count());
      }
      ans = min(ans, tmp);
    }
  }
  if (ans > k)
    puts("-1");
  else
    printf("%d\n", ans);
  return 0;
}
