#include <bits/stdc++.h>
using namespace std;
int N, M, K;
int Ar[110][110];
int Temp[110][110];
int Dn[110];
int Res = -1;
int f() {
  int rev = 0;
  for (int i = 1, a, b; i <= N; i++) {
    a = 0;
    b = 0;
    for (int j = 1; j <= M; j++) {
      a += (Ar[i][j] == Dn[j]);
      b += (Ar[i][j] != Dn[j]);
    }
    rev += min(a, b);
  }
  return rev;
}
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", &Temp[i][j]);
  if (N < M) {
    for (int i = 1; i <= N; i++)
      for (int j = 1; j <= M; j++) Ar[j][i] = Temp[i][j];
    int temp = N;
    N = M;
    M = temp;
  } else
    for (int i = 1; i <= N; i++)
      for (int j = 1; j <= M; j++) Ar[i][j] = Temp[i][j];
  if (N <= K) {
    for (int i = 0, mi = (1 << M); i < mi; i++) {
      for (int j = 1; j <= M; j++) Dn[j] = (i & (1 << (j - 1))) != 0;
      int temp = f();
      if (temp <= K && (Res == -1 || temp < Res)) Res = temp;
    }
  } else {
    for (int i = 1; i <= N; i++) {
      for (int j = 1; j <= M; j++) Dn[j] = Ar[i][j];
      int temp = f();
      if (temp <= K && (Res == -1 || temp < Res)) Res = temp;
    }
  }
  printf("%d\n", Res);
  return 0;
}
