#include <bits/stdc++.h>
using namespace std;
int N, M, K, Rez;
int A[110][110];
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]);
  Rez = N * M;
  for (int i = 1; i <= N; ++i) {
    int cost = 0;
    for (int k = 1; k <= N; ++k)
      if (i != k) {
        int sum = 0;
        for (int j = 1; j <= M; ++j) sum += A[i][j] ^ A[k][j];
        sum = min(sum, M - sum);
        cost += sum;
      }
    Rez = min(Rez, cost);
  }
  for (int i = 1; i <= M; ++i) {
    int cost = 0;
    for (int k = 1; k <= M; ++k)
      if (i != k) {
        int sum = 0;
        for (int j = 1; j <= N; ++j) sum += A[j][i] ^ A[j][k];
        sum = min(sum, N - sum);
        cost += sum;
      }
    Rez = min(Rez, cost);
  }
  int sum = 0;
  for (int i = 1; i <= N; ++i)
    for (int j = 1; j <= M; ++j) sum += A[i][j];
  sum = min(sum, N * M - sum);
  Rez = min(Rez, sum);
  printf("%d\n", Rez <= K ? Rez : -1);
  return 0;
}
