#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
inline bool mina(A &x, B y) {
  return (x > y) ? (x = y, 1) : 0;
}
template <typename A, typename B>
inline bool maxa(A &x, B y) {
  return (x < y) ? (x = y, 1) : 0;
}
int R, C, K;
int B[(104)][(104)];
int X[(104)];
int Y[(104)];
int main() {
  cin >> R >> C >> K;
  if (R == 1 || C == 1) {
    printf("0\n");
    return 0;
  }
  for (int _b = (R), i = (0); i < _b; ++i)
    for (int _b = (C), j = (0); j < _b; ++j) cin >> B[i][j];
  int sol = K + 1;
  if (R <= K) {
    for (int _b = (1 << R), b = (0); b < _b; ++b) {
      for (int _b = (R), i = (0); i < _b; ++i) X[i] = (b >> i) & 1;
      int res = 0;
      for (int _b = (C), i = (0); i < _b; ++i) {
        int c = 0;
        for (int _b = (R), j = (0); j < _b; ++j) c += X[j] ^ B[j][i];
        res += min(c, R - c);
      }
      mina(sol, res);
    }
  } else {
    for (int _b = (R), i = (0); i < _b; ++i) {
      for (int _b = (C), j = (0); j < _b; ++j) Y[j] = B[i][j];
      int res = 0;
      for (int _b = (R), j = (0); j < _b; ++j) {
        int c = 0;
        for (int _b = (C), k = (0); k < _b; ++k) c += Y[k] ^ B[j][k];
        res += min(c, C - c);
      }
      mina(sol, res);
    }
  }
  if (sol > K) sol = -1;
  printf("%d\n", sol);
  return 0;
}
