#include <bits/stdc++.h>
using namespace std;
int match_cost(vector<int> a, vector<int> b) {
  assert(a.size() == b.size());
  int cost = 0;
  for (int i = 0; i < a.size(); i++)
    if (a[i] != b[i]) cost++;
  return min(cost, (int)a.size() - cost);
}
int main() {
  int r, c, k;
  scanf("%d %d %d", &r, &c, &k);
  vector<vector<int> > a(r, vector<int>(c));
  int answer = 0;
  for (int i = 0; i < r; i++)
    for (int j = 0; j < c; j++) {
      scanf("%d", &a[i][j]);
    }
  int ans = 30;
  if (c < 20) {
    for (int m = 0; m < (1 << c); m++) {
      vector<int> row(c);
      for (int i = 0; i < c; i++)
        if (m & (1 << i)) row[i] = 1;
      int total = 0;
      for (int i = 0; i < r; i++) total += match_cost(row, a[i]);
      ans = min(ans, total);
    }
  } else {
    for (int i = 0; i < r; i++) {
      int total = 0;
      for (int j = 0; j < r; j++) total += match_cost(a[i], a[j]);
      ans = min(ans, total);
    }
  }
  printf("%d\n", ans <= k ? ans : -1);
  return 0;
}
