#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int a[100][100];
int main() {
  scanf("%d%d%d", &n, &m, &k);
  if (n >= m) {
    for (int i = 0; i < (int)(n); ++i)
      for (int j = 0; j < (int)(m); ++j) scanf("%d", a[i] + j);
  } else {
    for (int i = 0; i < (int)(n); ++i)
      for (int j = 0; j < (int)(m); ++j) scanf("%d", a[j] + i);
    swap(n, m);
  }
  if (n > k) {
    int best = 10005;
    for (int i = 0; i < (int)(n); ++i) {
      int tot = 0;
      for (int j = 0; j < (int)(n); ++j) {
        int cnt = 0;
        for (int q = 0; q < (int)(m); ++q) cnt += a[i][q] == a[j][q];
        tot += min(cnt, m - cnt);
      }
      best = min(best, tot);
    }
    if (best > k) best = -1;
    printf("%d\n", best);
  } else {
    int best = 10005;
    for (int mask = 0; mask < (int)(1 << m); ++mask) {
      int tot = 0;
      for (int i = 0; i < (int)(n); ++i) {
        int cnt = 0;
        for (int j = 0; j < (int)(m); ++j)
          cnt += a[i][j] == ((mask & (1 << j)) > 0);
        tot += min(cnt, m - cnt);
      }
      best = min(best, tot);
    }
    if (best > k) best = -1;
    printf("%d\n", best);
  }
  return 0;
}
