#include <bits/stdc++.h>
using namespace std;
int mat[105][105];
int n, m, k;
int n_t() {
  int ans = 20000;
  for (int i = 0; i < n; ++i) {
    int tmp = 0;
    for (int t = 0; t < n; ++t) {
      int rec1 = 0;
      int rec2 = 0;
      for (int k = 0; k < m; ++k) {
        if (mat[i][k] != mat[t][k]) rec1++;
        if (mat[i][k] == mat[t][k]) rec2++;
      }
      tmp += min(rec1, rec2);
    }
    ans = min(ans, tmp);
  }
  return ans;
}
int t_n() {
  int pos = (1 << n);
  int ans = 20000;
  for (int i = 0; i < pos; ++i) {
    int tmp = 0;
    for (int t = 0; t < m; ++t) {
      int rec1 = 0;
      int rec2 = 0;
      for (int j = 0; j < n; ++j) {
        int rec = i & (1 << j);
        if (rec == (mat[j][t] << j))
          rec1++;
        else
          rec2++;
      }
      if (rec1 + rec2 != n) {
        cout << "false" << endl;
        return 0;
      }
      tmp += min(rec1, rec2);
    }
    ans = min(ans, tmp);
  }
  return ans;
}
int main() {
  cin >> n >> m >> k;
  for (int i = 0; i < n; ++i) {
    for (int t = 0; t < m; ++t) {
      cin >> mat[i][t];
    }
  }
  int ans = 20000;
  if (n > k) {
    ans = n_t();
  }
  if (k >= n) {
    ans = t_n();
  }
  if (ans > k)
    cout << -1 << endl;
  else
    cout << ans << endl;
  return 0;
}
