#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int a[200][200];
int x[200], y[200];
void init_x() {
  for (int i = 0; i < n; ++i) x[i] = 0;
}
void next_x() {
  for (int i = n - 1; i >= 0; --i) {
    if (x[i] == 0) {
      x[i] = 1;
      for (int j = i + 1; j < n; ++j) x[j] = 0;
      return;
    }
  }
}
void get_best_y() {
  for (int j = 0; j < m; ++j) {
    int cnt = 0;
    for (int t = 0; t < n; ++t) {
      if (x[t] == a[t][j]) ++cnt;
    }
    if (cnt > n - cnt)
      y[j] = 0;
    else
      y[j] = 1;
  }
}
int get_perm() {
  int res = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) res += a[i][j] ^ x[i] ^ y[j];
  }
  return res;
}
void init_y(int row) {
  for (int j = 0; j < m; ++j) y[j] = a[row][j];
}
void get_best_x() {
  for (int i = 0; i < n; ++i) {
    int cnt = 0;
    for (int j = 0; j < m; ++j)
      if (y[j] == a[i][j]) ++cnt;
    if (cnt > m - cnt)
      x[i] = 0;
    else
      x[i] = 1;
  }
}
int main() {
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) scanf("%d", &a[i][j]);
  }
  int ans = 100500;
  if (n <= k) {
    init_x();
    for (int u = 0; u < (1 << n); ++u) {
      get_best_y();
      int change = get_perm();
      if (change <= k) ans = min(ans, change);
      next_x();
    }
  } else {
    for (int i = 0; i < n; ++i) {
      init_y(i);
      get_best_x();
      int change = get_perm();
      if (change <= k) ans = min(ans, change);
    }
  }
  printf("%d", (ans == 100500) ? -1 : ans);
  return 0;
}
