#include <bits/stdc++.h>
using namespace std;
int n, m, tab[105][105], pot[30];
int licz(int numer) {
  int wyn = 0;
  for (int i = (0); i <= ((m)-1); ++i) {
    int a = 0, b = 0;
    for (int j = (0); j <= ((n)-1); ++j) {
      a += (tab[j][i] != tab[j][numer]);
      b += (tab[j][i] == tab[j][numer]);
    }
    wyn += min(a, b);
  }
  return wyn;
}
int licz2(int a) {
  for (int i = (0); i <= ((n)-1); ++i) {
    tab[i][m] = a % 2;
    a /= 2;
  }
  return licz(m);
}
void jebaj() {
  pot[0] = 1;
  for (int i = (1); i <= (20); ++i) pot[i] = pot[i - 1] * 2;
  int k;
  cin >> n >> m >> k;
  for (int i = (0); i <= ((n)-1); ++i)
    for (int j = (0); j <= ((m)-1); ++j) cin >> tab[i][j];
  int res = 1000;
  if (n > k) {
    for (int i = (0); i <= ((k + 1) - 1); ++i) {
      res = min(res, licz(i));
    }
  } else {
    for (int i = (0); i <= ((pot[n]) - 1); ++i) {
      res = min(res, licz2(i));
    }
  }
  if (res > k) {
    cout << "-1\n";
    return;
  }
  cout << res << "\n";
  return;
}
int main() {
  ios_base::sync_with_stdio(0);
  int t;
  t = 1;
  for (int i = (0); i <= ((t)-1); ++i) jebaj();
}
