#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 0x3f3f3f3f3f3f3f3f;
long long n, m, _;
bool a[101][101];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m >> _;
  for (long long i = 0; i < n; i += 1) {
    for (long long j = 0; j < m; j += 1) {
      cin >> a[i][j];
    }
  }
  long long ans = INF;
  if (n > _) {
    for (long long i = 0; i < n; i += 1) {
      long long sum = 0;
      for (long long j = 0; j < n; j += 1) {
        long long tmp = 0;
        for (long long k = 0; k < m; k += 1) {
          tmp += (a[i][k] != a[j][k]);
        }
        sum += min(tmp, m - tmp);
      }
      ans = min(ans, sum);
    }
  } else {
    ;
    for (long long i = 0; i < (1 << n); i++) {
      long long sum = 0;
      for (long long k = 0; k < m; k += 1) {
        long long tmp = 0;
        for (long long j = 0; j < n; j += 1) {
          tmp += ((1 & (i >> j)) != a[j][k]);
        }
        sum += min(tmp, n - tmp);
      }
      ans = min(ans, sum);
    }
  };
  cout << (ans > _ ? -1 : ans) << '\n';
  return 0;
}
