#include <bits/stdc++.h>
template <class T>
inline void maz(T &a, T b) {
  if (a < b) a = b;
}
template <class T>
inline void miz(T &a, T b) {
  if (a > b) a = b;
}
template <class T>
inline T abs(T a) {
  return a > 0 ? a : -a;
}
using namespace std;
int n, m, k;
int check(bool *a, bool *b) {
  int tot = 0;
  for (int i = 0; i < n; i++) tot += (a[i] ^ b[i]);
  return tot;
}
int main() {
  bool t[110][110], p[110][110];
  int ans;
  scanf("%d%d%d", &n, &m, &k);
  ans = k + 1;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) scanf("%d", &t[i][j]), p[j][i] = t[i][j];
  if (n > k) {
    for (int i = 0; i < m; i++) {
      bool tmp1[110], tmp2[110];
      int tot = 0;
      for (int j = 0; j < n; j++) tmp1[j] = t[j][i], tmp2[j] = !tmp1[j];
      for (int j = 0; j < m; j++) {
        tot +=
            ((check(tmp1, p[j])) < (check(tmp2, p[j])) ? (check(tmp1, p[j]))
                                                       : (check(tmp2, p[j])));
      }
      miz(ans, tot);
    }
  } else {
    for (int i = 0; i < (1 << n); i++) {
      bool tmp1[110], tmp2[110];
      int tot = 0;
      for (int j = 0; j < n; j++) {
        tmp1[j] = (i & (1 << j));
        tmp2[j] = !tmp1[j];
      }
      for (int j = 0; j < m; j++)
        tot +=
            ((check(tmp1, p[j])) < (check(tmp2, p[j])) ? (check(tmp1, p[j]))
                                                       : (check(tmp2, p[j])));
      miz(ans, tot);
    }
  }
  if (ans > k)
    puts("-1");
  else
    printf("%d\n", ans);
}
