#include <bits/stdc++.h>
using namespace std;
const int NMAX = 110;
int N, M, K, A[NMAX][NMAX], Ans = 11;
int main() {
  scanf("%i %i %i", &N, &M, &K);
  for (int i = 0; i < N; ++i)
    for (int j = 0; j < M; ++j) scanf("%i", &A[i][j]);
  if (N <= K) {
    for (int Conf = 0; Conf < (1 << N); ++Conf) {
      int Total = 0;
      for (int j = 0; j < M && Total <= K; ++j) {
        int Now = 0;
        for (int i = 0; i < N; ++i) {
          int Bit = (Conf & (1 << i)) > 0;
          Now += A[i][j] != Bit;
        }
        Total += min(Now, N - Now);
      }
      if (Total <= K) Ans = min(Ans, Total);
    }
  } else {
    for (int i = 0; i < N; ++i) {
      int Total = 0;
      for (int j = 0; j < N && Total <= K; ++j)
        if (i != j) {
          int Now = 0;
          for (int k = 0; k < M; ++k) Now += A[j][k] != A[i][k];
          Total += min(Now, M - Now);
        }
      if (Total <= K) Ans = min(Ans, Total);
    }
  }
  if (Ans == 11)
    printf("-1");
  else
    printf("%i", Ans);
}
