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