#include <bits/stdc++.h>
using namespace std;
const int maxk = 1050, maxn = 105, inf = 1e5 + 20;
int n, m, k, dp[maxk][maxn], ans = inf, a[maxn][maxn];
int mask_dif(int mask, int e) {
  int t = 0;
  for (int i = 0; i < n; i++) {
    int x = ((mask & (1 << i)) > 0);
    int y = a[i][e];
    t += (x != y);
  }
  return t;
}
int row_dif(int x, int y) {
  int t = 0;
  for (int i = 0; i < m; i++) t += (a[x][i] != a[y][i]);
  return t;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> a[i][j];
  if (n <= 10) {
    for (int mask = 0; mask < (1 << n); mask++) {
      dp[mask][0] = 0;
      for (int j = 1; j <= m; j++) {
        int x = mask_dif(mask, j - 1);
        dp[mask][j] = dp[mask][j - 1] + min(x, n - x);
      }
      ans = min(ans, dp[mask][m]);
    }
    return cout << (ans <= k ? ans : -1) << endl, 0;
  }
  for (int i = 0; i < n; i++) {
    int x = 0;
    for (int j = 0; j < n; j++) {
      int w = row_dif(i, j);
      x += (min(w, m - w));
    }
    ans = min(ans, x);
  }
  cout << (ans <= k ? ans : -1) << endl;
  return 0;
}
