#include <bits/stdc++.h>
using namespace std;
int a[100][100], w, h, k;
int main() {
  scanf("%d%d%d", &h, &w, &k);
  for (int i = 0; i < h; ++i)
    for (int j = 0; j < w; ++j) scanf("%d", a[i] + j);
  int ans = 1e9;
  if (k < w) {
    for (int u = 0; u < w; ++u) {
      int cnt = 0;
      for (int v = 0; v < w; ++v) {
        int cc = 0;
        for (int j = 0; j < h; ++j) cc += (a[j][u] != a[j][v]);
        cnt += min(cc, h - cc);
      }
      ans = min(ans, cnt);
    }
  } else {
    assert(w <= 10);
    for (int z = 0; z < 1 << w; ++z) {
      int cnt = 0;
      for (int i = 0; i < h; ++i) {
        int cc = 0;
        for (int j = 0; j < w; ++j) cc += (a[i][j] == (z >> j & 1));
        cnt += min(cc, w - cc);
      }
      ans = min(ans, cnt);
    }
  }
  if (ans > k) ans = -1;
  printf("%d\n", ans);
}
