#include <bits/stdc++.h>
const int inf = 0xfffffff;
const long long INF = 1ll << 61;
using namespace std;
int n, s, k;
int aa[100 + 55][100 + 55];
int ans;
void init() { memset(aa, 0, sizeof(aa)); }
bool input() {
  while (scanf("%d %d %d", &n, &s, &k) == 3) {
    for (int i = 0; i < n; i++)
      for (int j = 0; j < s; j++) scanf("%d", &aa[i][j]);
    return false;
  }
  return true;
}
void cal() {
  ans = 11;
  if (n < s) {
    for (int i = 0; i < s; i++)
      for (int j = i + 1; j < s; j++) swap(aa[i][j], aa[j][i]);
    swap(n, s);
  }
  if (n <= k) {
    for (int i = 0; i < (1 << s); i++) {
      int sum = 0;
      for (int j = 0; j < n; j++) {
        int now = 0;
        for (int l = 0; l < s; l++) {
          if (i & (1 << l)) {
            if (!aa[j][l]) now++;
          } else {
            if (aa[j][l]) now++;
          }
        }
        sum += min(now, s - now);
      }
      ans = min(ans, sum);
    }
  } else {
    for (int i = 0; i < n; i++) {
      int sum = 0;
      for (int j = 0; j < n; j++) {
        int now = 0;
        for (int l = 0; l < s; l++) {
          if (aa[i][l] != aa[j][l]) now++;
        }
        sum += min(now, s - now);
      }
      ans = min(ans, sum);
    }
  }
}
void output() {
  if (ans <= k)
    cout << ans << endl;
  else
    puts("-1");
}
int main() {
  while (true) {
    init();
    if (input()) return 0;
    cal();
    output();
  }
}
