#include <bits/stdc++.h>
using namespace ::std;
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 += min(op, m - op);
      }
      ans = min(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 += min(op, n - op);
      }
      ans = min(ans, an);
    }
  }
  if (ans > k)
    printf("-1");
  else
    printf("%d", ans);
  return 0;
}
