#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int n, m, k, ans, a[N][N], p[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie();
  cout.tie();
  cin >> n >> m >> k;
  ans = k + 1;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) cin >> a[i][j];
  if (n <= k) {
    for (int i = 0; i < 1 << n; ++i) {
      int res = 0;
      for (int j = 0; j < m; ++j) {
        int c = 0;
        for (int k = 0; k < n; ++k)
          if ((i >> k & 1) ^ a[k][j]) ++c;
        res += min(c, n - c);
      }
      ans = min(ans, res);
    }
  } else {
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < m; ++j) p[j] = a[i][j];
      int res = 0;
      for (int k = 0; k < n; ++k) {
        int c = 0;
        for (int j = 0; j < m; ++j)
          if (a[k][j] ^ p[j]) ++c;
        res += min(c, m - c);
      }
      ans = min(ans, res);
    }
  }
  if (ans > k) ans = -1;
  cout << ans;
  return 0;
}
