#include <bits/stdc++.h>
using namespace std;
const int inft = 1000000009;
const int MAXN = 106;
bitset<MAXN> B[MAXN];
int A[MAXN][MAXN], A2[MAXN][MAXN];
int main() {
  int n, m, k;
  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 ret = 12;
  for (int o = 0; o < (2); ++o) {
    for (int i = 0; i < (MAXN); ++i) B[i].reset();
    for (int i = 0; i < (n); ++i)
      for (int j = 0; j < (m); ++j) B[i][j] = A[i][j];
    for (int i = 0; i < (n); ++i) {
      bitset<MAXN> B2 = B[i];
      for (int j = 0; j < (m); ++j) B2[j] = B2[j] ^ 1;
      int t = 0;
      for (int j = 0; j < (n); ++j)
        t += min((B[i] ^ B[j]).count(), (B2 ^ B[j]).count());
      ret = min(ret, t);
    }
    if (m < 12)
      for (int mask = 0; mask < ((1 << m)); ++mask) {
        bitset<MAXN> B1, B2;
        for (int j = 0; j < (m); ++j)
          if (mask & (1 << j))
            B1[j] = 1;
          else
            B2[j] = 1;
        int t = 0;
        for (int j = 0; j < (n); ++j)
          t += min((B1 ^ B[j]).count(), (B2 ^ B[j]).count());
        ret = min(ret, t);
      }
    for (int i = 0; i < (n); ++i)
      for (int j = 0; j < (m); ++j) A2[i][j] = A[i][j];
    swap(n, m);
    for (int i = 0; i < (n); ++i)
      for (int j = 0; j < (m); ++j) A[i][j] = A2[j][i];
  }
  if (ret > k) ret = -1;
  printf("%d\n", ret);
  return 0;
}
