#include <bits/stdc++.h>
using namespace std;
const unsigned long long MOD = 1e9 + 7;
int read() {
  char ch = ' ';
  while (ch < '0' || ch > '9') ch = getchar();
  int x = 0;
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x;
}
int n, m, k, ans;
int a[105][105];
int d[3][105];
int a1[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]);
    }
  ans = 2140000000;
  if (n > 10) {
    for (int i = 1; i <= n; i++) {
      int an = 0;
      for (int j = 1; j <= n; j++) {
        int op = 0;
        for (int k = 1; k <= m; k++)
          if (a[i][k] != a[j][k]) op++;
        an += ((op) < (m - op) ? (op) : (m - op));
      }
      ans = ((ans) < (an) ? (ans) : (an));
    }
  } else {
    for (int i = 0; i < (1 << n); i++) {
      for (int j = 0; j < n; j++) {
        if ((i & (1 << j)) != 0)
          a1[j] = 1;
        else
          a1[j] = 0;
      }
      int an = 0;
      for (int j = 1; j <= m; j++) {
        int op = 0;
        for (int k = 1; k <= n; k++)
          if (a[k][j] != a1[k - 1]) op++;
        an += ((op) < (n - op) ? (op) : (n - op));
      }
      ans = ((ans) < (an) ? (ans) : (an));
    }
  }
  if (ans > k)
    printf("-1");
  else
    printf("%d", ans);
  return 0;
}
