#include <bits/stdc++.h>
int a[105][105], f[105];
using namespace std;
int main() {
  int n, m, k, ans = 0x7fffffff;
  cin >> n >> m >> k;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) cin >> a[i][j];
  if (n > 10) {
    for (int i = 1; i <= n; i++) {
      int tans = 0;
      for (int j = 1; j <= n; j++) {
        int p = 0;
        for (int r = 1; r <= m; r++) p += (a[j][r] == a[i][r]);
        tans += min(p, m - p);
      }
      ans = min(ans, tans);
    }
  } else {
    for (int i = 0; i < (1 << n); i++) {
      for (int j = 1; j <= n; j++) f[j] = ((i >> (j - 1)) & 1);
      int tans = 0;
      for (int j = 1; j <= m; j++) {
        int p = 0;
        for (int r = 1; r <= n; r++) p += (a[r][j] == f[r]);
        tans += min(p, n - p);
      }
      ans = min(ans, tans);
    }
  }
  if (ans <= k)
    printf("%d\n", ans);
  else
    printf("-1\n");
  return 0;
}
