#include <bits/stdc++.h>
using namespace std;
const int N = 104;
int a[N][N], n, m, k;
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 = N * N;
  if (n <= k) {
    for (int i = 0; i < 1 << n; i++) {
      int sum = 0;
      for (int j = 1; j <= m; j++) {
        int diff = 0;
        for (int l = 1; l <= n; l++)
          if (a[l][j] != (!!(i & 1 << l))) diff++;
        if (diff > n - diff) diff = n - diff;
        sum += diff;
      }
      ans = min(ans, sum);
    }
  } else {
    for (int i = 0; i < n; i++) {
      int sum = 0;
      for (int l = 1; l <= n; l++) {
        int diff = 0;
        for (int j = 1; j <= m; j++)
          if (a[l][j] != a[i][j]) diff++;
        if (diff > m - diff) diff = m - diff;
        sum += diff;
      }
      ans = min(ans, sum);
    }
  }
  if (ans <= k)
    printf("%d", ans);
  else
    printf("-1");
  return 0;
}
