#include <bits/stdc++.h>
using namespace std;
using lli = long long int;
const int MOD = 1000000007;
const int MOD1 = 998244353;
const int maxn = 100010;
const int lim = (int)1e9;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n = 0, m = 0, k = 0, res = lim;
  cin >> n >> m >> k;
  vector<vector<int> > a(n, vector<int>(m));
  for (auto &i : a)
    for (auto &j : i) cin >> j;
  for (int i = 0; i < n; ++i) {
    int ct = 0;
    bool flag = false;
    for (int j = 0; j < n; ++j) {
      int x = 0, y = 0;
      for (int l = 0; l < m; ++l) {
        if (a[j][l] != a[i][l])
          ++x;
        else
          ++y;
      }
      ct += min(x, y);
      if (ct > k) {
        flag = true;
        break;
      }
    }
    if (!flag) res = min(res, ct);
  }
  for (int i = 0; i < m; ++i) {
    int ct = 0;
    bool flag = false;
    for (int j = 0; j < m; ++j) {
      int x = 0, y = 0;
      for (int l = 0; l < n; ++l) {
        if (a[l][j] != a[l][i])
          ++x;
        else
          ++y;
      }
      ct += min(x, y);
      if (ct > k) {
        flag = true;
        break;
      }
    }
    if (!flag) res = min(res, ct);
  }
  int x = 0, y = 0;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) {
      if (a[i][j] == 0)
        ++x;
      else
        ++y;
    }
  res = min({res, x, y});
  cout << (res > k ? -1 : res);
}
