#include <bits/stdc++.h>
using namespace std;
const int maxn = 128;
const int inf = 0x3f3f3f3f;
int n, m, k;
int a[maxn][maxn];
int solveC(int c) {
  int ans = 0;
  for (int j = 0; j < m; ++j) {
    int cost = 0;
    for (int i = 0; i < n; ++i) {
      cost += (a[i][j] == a[i][c] ? 0 : 1);
    }
    ans += min(cost, n - cost);
  }
  return ans;
}
int solveR(int mask) {
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    int cost = 0;
    for (int j = 0; j < m; ++j) {
      cost += (a[i][j] == (1 & (mask >> j)) ? 0 : 1);
    }
    ans += min(cost, m - cost);
  }
  return ans;
}
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", &a[i][j]);
  int ans = inf;
  if (k < m) {
    for (int j = 0; j < m; ++j) {
      ans = min(ans, solveC(j));
    }
  } else {
    for (int mask = 0; mask < (1 << m); ++mask) {
      ans = min(ans, solveR(mask));
    }
  }
  if (ans <= k) {
    printf("%d\n", ans);
  } else {
    printf("-1\n");
  }
}
