#include <bits/stdc++.h>
using namespace std;
const int oo = 2000000009;
const double eps = 1e-9;
const int mx = 102;
int n, m, k;
int a[mx][mx];
int b[mx][mx];
int start[mx];
int get() {
  int ret = 0;
  for (int i = 0; i < (n); ++i) {
    int c1 = 0, c2 = 0;
    for (int j = 0; j < (m); ++j) {
      if (b[i][j] == start[j])
        ++c1;
      else
        ++c2;
    }
    ret += min(c1, c2);
  }
  return ret;
}
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]);
  if (n < m) {
    swap(n, m);
    for (int i = 0; i < (n); ++i)
      for (int j = 0; j < (m); ++j) b[i][j] = a[j][i];
  } else {
    for (int i = 0; i < (n); ++i)
      for (int j = 0; j < (m); ++j) b[i][j] = a[i][j];
  }
  int ans = oo;
  if (n <= k) {
    for (int mask = 0; mask < ((1 << m)); ++mask) {
      for (int i = 0; i < (m); ++i) start[i] = 0;
      for (int i = 0; i < (m); ++i)
        if (mask & (1 << i)) start[i] = 1;
      ans = min(ans, get());
    }
  }
  for (int i = 0; i < (n); ++i) {
    for (int j = 0; j < (m); ++j) start[j] = b[i][j];
    ans = min(ans, get());
  }
  if (ans > k) ans = -1;
  printf("%d\n", ans);
  return 0;
}
