#include <bits/stdc++.h>
using namespace std;
inline int geti() {
  int n;
  scanf("%d", &n);
  return n;
}
inline void geti(int& n) { scanf("%d", &n); }
inline double getf() {
  double n;
  scanf("%f", &n);
  return n;
}
inline void getf(double& n) { scanf("%f", &n); }
template <typename T>
void trace(T n) {}
template <typename T>
void traceln(T n) {}
void pause() {}
int x, y, k;
int d[200][200];
int mincost = 0x7FFFFFFF;
void trans() {
  for (int(i) = (0); (i) <= (99); (i)++)
    for (int(j) = (i + 1); (j) <= (99); (j)++) swap(d[i][j], d[j][i]);
  swap(x, y);
}
void findbrute() {
  int brutemax = 1 << y;
  int cankao[10];
  for (int(brute) = (0); (brute) <= (brutemax - 1); (brute)++) {
    int q = brute;
    for (int(i) = (0); (i) <= (y - 1); (i)++) {
      cankao[i] = q & 1;
      q >>= 1;
    }
    int cost = 0;
    for (int(i) = (0); (i) <= (x - 1); (i)++) {
      int same = 0;
      for (int(j) = (0); (j) <= (y - 1); (j)++)
        if (d[i][j] == cankao[j]) same++;
      same = min(same, y - same);
      cost += same;
    }
    mincost = min(cost, mincost);
  }
}
void findfix() {
  for (int(kijun) = (0); (kijun) <= (x - 1); (kijun)++) {
    int cost = 0;
    for (int(i) = (0); (i) <= (x - 1); (i)++) {
      int same = 0;
      for (int(j) = (0); (j) <= (y - 1); (j)++)
        if (d[i][j] == d[kijun][j]) same++;
      same = min(same, y - same);
      cost += same;
    }
    mincost = min(cost, mincost);
  }
}
int main() {
  x = geti();
  y = geti();
  k = geti();
  if (x == 1 || y == 1) {
    cout << 0 << endl;
    return 0;
  }
  for (int(i) = (0); (i) <= (x - 1); (i)++)
    for (int(j) = (0); (j) <= (y - 1); (j)++) d[i][j] = geti();
  if (y <= 10)
    findbrute();
  else if (x <= 10) {
    trans();
    findbrute();
  } else {
    findfix();
    trans();
    findfix();
  }
  if (mincost > k)
    cout << -1 << endl;
  else
    cout << mincost << endl;
  pause();
}
