#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long long maxN = 300005;
const long long oo = 1e18 + 7;
long long n;
long long x, y, z, k;
long long thelimitneverused;
long long ans = mod;
long long m;
bool a[105][105];
long long rw[105];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m >> thelimitneverused;
  for (long long i = 1; i <= n; ++i)
    for (long long j = 1; j <= m; ++j) cin >> a[i][j];
  memset(rw, 0, sizeof(rw));
  if (m <= 10) {
    for (long long i = 1; i <= n; ++i)
      for (long long j = 1; j <= m; ++j) rw[i] = rw[i] * 2 + a[i][j];
    for (long long mask = 0; mask <= (1 << m) - 1; ++mask) {
      long long res = 0;
      for (long long i = 1; i <= n; ++i) {
        x = __builtin_popcount(rw[i] ^ mask);
        res += min(x, m - x);
      }
      ans = min(ans, res);
    }
  } else {
    for (long long i = 1; i <= m; ++i) {
      long long res = 0;
      for (long long j = 1; j <= m; ++j) {
        x = 0;
        for (long long l = 1; l <= n; ++l) {
          x += (a[l][i] != a[l][j]);
        }
        res += min(x, n - x);
      }
      ans = min(ans, res);
    }
  }
  if (ans > thelimitneverused)
    cout << "-1\n";
  else
    cout << ans << "\n";
}
