#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, m, k;
  cin >> n >> m >> k;
  vector<vector<long long>> a(n, vector<long long>(m));
  for (auto &x : a)
    for (auto &y : x) cin >> y;
  long long res = n * m;
  if (m <= k) {
    for (long long mask = 0; mask < 1 << k; mask++) {
      long long tr = 0;
      for (long long i = 0; i < n; i++) {
        long long x = 0, y = 0;
        for (long long j = 0; j < m; j++) {
          if (bool(mask & (1 << j)) != a[i][j]) {
            x++;
          } else {
            y++;
          }
        }
        tr += min(x, y);
      }
      res = min(res, tr);
    }
  } else {
    for (long long idx = 0; idx < m; idx++) {
      long long tr = 0;
      for (long long j = 0; j < m; j++) {
        long long x = 0, y = 0;
        for (long long i = 0; i < n; i++) {
          if (a[i][j] != a[i][idx]) {
            x++;
          } else {
            y++;
          }
        }
        tr += min(x, y);
      }
      res = min(res, tr);
    }
  }
  cout << (res <= k ? res : -1);
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
  return 0;
}
