#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100 + 10;
int n, m, a[MAXN][MAXN], k;
int check(int j) {
  int Tohka = 0;
  for (int i = 1; i <= m; ++i) {
    int t[2] = {0, 0};
    for (int p = 1; p <= n; ++p) ++t[a[p][i] ^ a[p][j]];
    Tohka += min(t[0], t[1]);
  }
  return Tohka;
}
int main() {
  cin >> n >> m >> k;
  bool flag = false;
  if (m < n) flag = true;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= m; ++j) scanf("%d", &((flag) ? (a[j][i]) : (a[i][j])));
  if (flag) swap(n, m);
  int Tohka = MAXN;
  if (m > k)
    for (int i = 1; i <= m; ++i) Tohka = min(Tohka, check(i));
  else
    for (int i = 1; i <= m; ++i)
      for (int j = 0; j < (1 << n); ++j) {
        int cnt = 0;
        for (int p = 0; p < n; ++p)
          if ((j >> p) & 1) a[p + 1][i] ^= 1, ++cnt;
        Tohka = min(Tohka, check(i) + cnt);
        for (int p = 0; p < n; ++p)
          if ((j >> p) & 1) a[p + 1][i] ^= 1;
      }
  if (Tohka <= k)
    cout << Tohka << endl;
  else
    puts("-1");
  fclose(stdin);
  fclose(stdout);
  return 0;
}
