#include <bits/stdc++.h>
using namespace std;
int i, i0, n, m, k, ans, a[105][105];
int cal(int x) {
  int res = 0;
  for (int i = 1; i <= n; i++) {
    int v = 0;
    for (int i0 = 1; i0 <= m; i0++) {
      v += a[x][i0] == a[i][i0];
    }
    res += min(v, m - v);
  }
  return res;
}
int cal0(int state) {
  int res = 0;
  for (int i = 1; i <= n; i++) {
    a[i][0] = !!(state & (1 << (i - 1)));
  }
  for (int i = 1; i <= m; i++) {
    int v = 0;
    for (int i0 = 1; i0 <= n; i0++) {
      v += a[i0][0] == a[i0][i];
    }
    res += min(v, n - v);
  }
  return res;
}
int main() {
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 1; i <= n; i++)
    for (int i0 = 1; i0 <= m; i0++) scanf("%d", &a[i][i0]);
  ans = INT_MAX;
  if (n > k) {
    for (int i = 1; i <= k + 1; i++) {
      ans = min(ans, cal(i));
    }
  } else {
    for (int i = 0; i < (1 << n); i++) {
      ans = min(ans, cal0(i));
    }
  }
  if (ans > k) ans = -1;
  printf("%d\n", ans);
  return 0;
}
