#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int t[110][110];
int check1(int xi) {
  int ret = 0;
  for (int i = 0; i < n; i++) {
    int x = 0;
    for (int j = 0; j < m; j++) {
      if (t[i][j] == t[xi][j]) x++;
    }
    ret += min(x, m - x);
    if (ret > k) return k + 1;
  }
  return ret;
}
bool is1(int S, int i) { return S & (1 << i); }
int check2(int S) {
  int ret = 0;
  for (int i = 0; i < n; i++) {
    if (t[i][0] != is1(S, i)) ret++;
  }
  for (int i = 1; i < m; i++) {
    int x = 0;
    for (int j = 0; j < n; j++) {
      if (t[j][i] == is1(S, j)) x++;
    }
    ret += min(x, n - x);
    if (ret > k) return k + 1;
  }
  return ret;
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int(i) = 0; (i) < (n); ++(i)) {
    for (int(j) = 0; (j) < (m); ++(j)) {
      scanf("%d", &t[i][j]);
    }
  }
  int ans = k + 1;
  if (n > k) {
    for (int i = 0; i < n; i++) ans = min(ans, check1(i));
  } else {
    int ALL = 1 << n;
    ALL--;
    for (int i = 0; i <= ALL; i++) {
      int x = check2(i);
      ans = min(ans, x);
    }
  }
  if (ans > k) ans = -1;
  printf("%d\n", ans);
  return 0;
}
