#include <bits/stdc++.h>
using namespace std;
int G[110][110];
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 1; i <= (n); i++)
    for (int j = 1; j <= (m); j++) cin >> G[i][j];
  int ans = 1e7, sum, t;
  if (n > k) {
    for (int x = 1; x <= (n); x++) {
      sum = 0;
      for (int i = 1; i <= (n); i++) {
        t = 0;
        for (int j = 1; j <= (m); j++) t += G[i][j] ^ G[x][j];
        sum += min(t, m - t);
      }
      ans = min(ans, sum);
    }
  } else {
    for (int x = 0; x < (1 << n); x++) {
      sum = 0;
      for (int j = 1; j <= (m); j++) {
        t = 0;
        for (int i = 1; i <= (n); i++) t += G[i][j] ^ ((x >> (i - 1)) & 1);
        sum += min(t, n - t);
      }
      ans = min(sum, ans);
    }
  }
  if (ans > k) ans = -1;
  cout << ans << endl;
  return 0;
}
