#include <bits/stdc++.h>
#pragma comment(linker, "/stack:16777216")
using namespace std;
template <class T>
void out(map<char, T> &a, string s = "(%3c ->%3d)") {
  for (auto(it) = (a).begin(); (it) != (a).end(); ++(it))
    printf(s.c_str(), it->first, it->second);
  printf("\n");
}
template <class T>
void out(vector<T> &a, string s = "%3d ") {
  int i, n = a.size();
  for ((i) = 0; (i) < (n); (i)++) printf(s.c_str(), a[i]);
  printf("\n");
}
template <class T>
void out(T *a, int n, string s = "%3d ") {
  int i;
  for ((i) = 0; (i) < (n); (i)++) printf(s.c_str(), a[i]);
  printf("\n");
}
long long i, j, N, M, n, m, k, p;
int MainSolve(string args = "") {
  cout << args;
  int n, m, k, u;
  cin >> n >> m >> k;
  int const NMAX = 102;
  int a[NMAX][NMAX];
  if (n > m)
    for ((i) = 0; (i) < (n); (i)++)
      for ((j) = 0; (j) < (m); (j)++) cin >> a[i][j];
  else {
    swap(n, m);
    for ((j) = 0; (j) < (m); (j)++)
      for ((i) = 0; (i) < (n); (i)++) cin >> a[i][j];
  }
  int ans = k + 1;
  if (n > k) {
    for ((u) = 0; (u) < (n); (u)++) {
      int sm = 0;
      for ((i) = 0; (i) < (n); (i)++) {
        int dif = 0;
        for ((j) = 0; (j) < (m); (j)++) {
          dif += a[i][j] ^ a[u][j];
        }
        dif = min(dif, m - dif);
        sm += dif;
      }
      ans = min(ans, sm);
    }
  } else {
    for ((u) = 0; (u) < (1ll << m); (u)++) {
      int sm = 0;
      for ((i) = 0; (i) < (n); (i)++) {
        int dif = 0;
        for ((j) = 0; (j) < (m); (j)++) {
          dif += a[i][j] ^ ((bool)(u & (1ll << j)));
        }
        dif = min(dif, m - dif);
        sm += dif;
      }
      ans = min(ans, sm);
    }
  }
  if (ans > k)
    cout << -1 << endl;
  else
    cout << ans << endl;
  return 0;
}
string ReadAllLines(char *fileName) {
  string s = "";
  const int NMAX = 1000;
  char buf[NMAX];
  buf[0] = 0;
  FILE *f = fopen(fileName, "r");
  while (fgets(buf, NMAX, f)) s = s + string(buf);
  return string(s.begin(), find_if(s.rbegin(), s.rend(), [](char c) {
                             return c != '\n' && c != '\r' && c != '\t' &&
                                    c != ' ';
                           }).base());
}
int main() {
  MainSolve();
  return 0;
}
