#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int const N = 100 + 3;
int a[N][N];
int solve(vector<int> x) {
  int cand = 0;
  for (int p = (0); p < (n); ++p) {
    int cand0 = 0;
    int cand1 = 0;
    for (int j = (0); j < (m); ++j) {
      if ((x[j] ^ 0) != a[p][j])
        ++cand0;
      else
        ++cand1;
    }
    cand += min(cand0, cand1);
  }
  return cand;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m >> k;
  for (int i = (0); i < (n); ++i) {
    for (int j = (0); j < (m); ++j) {
      cin >> a[i][j];
    }
  }
  int rec = 1e9;
  if (n > k) {
    for (int i = (0); i < (n); ++i) {
      vector<int> x;
      for (int j = (0); j < (m); ++j) {
        x.push_back(a[i][j]);
      }
      int cand = solve(x);
      rec = min(cand, rec);
      for (int j = (0); j < (m); ++j) {
        x[j] = !(bool)x[j];
      }
      cand = solve(x);
      rec = min(cand, rec);
    }
  } else {
    int bin = 0;
    while (bin <= (1 << n)) {
      vector<int> y;
      int bx = bin;
      for (int i = (0); i < (n); ++i) {
        y.push_back(bx & 1);
        bx /= 2;
      }
      ++bin;
      int cand = 0;
      for (int j = (0); j < (m); ++j) {
        int cand0 = 0;
        int cand1 = 0;
        for (int p = (0); p < (n); ++p) {
          if ((y[p] ^ 0) != a[p][j])
            ++cand0;
          else
            ++cand1;
        }
        cand += min(cand0, cand1);
      }
      rec = min(cand, rec);
    }
  }
  if (rec <= k) {
    cout << rec << '\n';
  } else {
    cout << -1 << '\n';
  }
  return 0;
}
