#include <bits/stdc++.h>
const int INF = 2147483647;
int grd[101][101];
int N, M, K;
int tmp[101];
int ans = INF;
inline int min(int a, int b) { return a < b ? a : b; }
int calc1() {
  int ret = 0;
  for (int i = 0; i < N; ++i) {
    int t = 0;
    for (int j = 0; j < M; ++j) {
      if (grd[i][j] != tmp[j]) ++t;
    }
    ret += min(t, M - t);
  }
  return ret;
}
int calc2() {
  int ret = 0;
  for (int i = 0; i < M; ++i) {
    int t = 0;
    for (int j = 0; j < N; ++j) {
      if (grd[j][i] != tmp[j]) ++t;
    }
    ret += min(t, N - t);
  }
  return ret;
}
void solve1() {
  int lim = (1 << M) - 1;
  for (int i = 0; i <= lim; ++i) {
    for (int j = 0; j < M; ++j) tmp[j] = ((1 << j) & i) != 0;
    ans = min(ans, calc1());
  }
}
void solve2() {
  for (int i = 0; i < M; ++i) {
    for (int j = 0; j < N; ++j) tmp[j] = grd[j][i];
    ans = min(ans, calc2());
  }
}
int main() {
  scanf("%d%d%d", &N, &M, &K);
  for (int i = 0; i < N; ++i)
    for (int j = 0; j < M; ++j) scanf("%d", &grd[i][j]);
  if (M <= K)
    solve1();
  else
    solve2();
  printf("%d\n", ans <= K ? ans : -1);
}
