#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m, k;
  cin >> n >> m >> k;
  vector<bitset<100>> myVec(n, bitset<100>());
  vector<bitset<100>> myVec2(m, bitset<100>());
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      long long z;
      cin >> z;
      myVec[i][j] = z;
      myVec2[j][i] = z;
    }
  }
  bitset<100> allZ;
  bitset<100> allO;
  for (int j = 0; j < m; j++) {
    allO[j] = 1;
  }
  bitset<100> allO2;
  for (int j = 0; j < n; j++) {
    allO2[j] = 1;
  }
  myVec.push_back(allZ);
  myVec2.push_back(allZ);
  myVec.push_back(allO);
  myVec2.push_back(allO2);
  long long ans = INT_MAX;
  for (int i = 0; i < n + 2; i++) {
    long long minians = 0;
    for (int j = 0; j < n; j++) {
      long long intoI = (myVec[j] ^ myVec[i]).count();
      long long intoNotI = (myVec[j] ^ myVec[i] ^ allO).count();
      minians += min(intoI, intoNotI);
    }
    ans = min(ans, minians);
  }
  for (int i = 0; i < m + 2; i++) {
    long long minians = 0;
    for (int j = 0; j < m; j++) {
      long long intoI = (myVec2[j] ^ myVec2[i]).count();
      long long intoNotI = (myVec2[j] ^ myVec2[i] ^ allO2).count();
      minians += min(intoI, intoNotI);
    }
    ans = min(ans, minians);
  }
  if (ans > k) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }
}
