#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, k;
  int N, M, K;
  cin >> N >> M >> K;
  vector<vector<int> > a(N, vector<int>(M));
  for (i = 0; i < N; i++)
    for (j = 0; j < M; j++) cin >> a[i][j];
  if (M > N && M != 1) {
    vector<vector<int> > tmp(M, vector<int>(N));
    for (i = 0; i < N; i++)
      for (j = 0; j < M; j++) tmp[j][i] = a[i][j];
    a = tmp;
    swap(N, M);
  }
  int ans = 1000 * 1000 * 1000;
  int rev, sum_rev;
  if (M > K) {
    for (k = 0; k < N; k++) {
      sum_rev = 0;
      for (i = 0; i < N; i++) {
        rev = 0;
        for (j = 0; j < M; j++)
          if (a[i][j] != a[k][j]) rev++;
        sum_rev += min(rev, M - rev);
      }
      ans = min(ans, sum_rev);
    }
  } else {
    for (k = 0; k < (1 << M); k++) {
      vector<int> mask(M);
      for (i = 0; i < M; i++) mask[i] = ((k & (1 << i)) > 0);
      sum_rev = 0;
      for (i = 0; i < N; i++) {
        rev = 0;
        for (j = 0; j < M; j++) rev += (a[i][j] != mask[j]);
        sum_rev += min(rev, M - rev);
      }
      ans = min(ans, sum_rev);
    }
  }
  if (ans > K)
    cout << "-1";
  else
    cout << ans;
  cout << endl;
}
