#include <bits/stdc++.h>
using namespace std;
int n, m, k, sta[105], stt[105];
int mm[105][105];
int cal(int x, int cou) {
  int ret = 0;
  for (int i = 0; i < cou; i++) {
    ret += (x & 1);
    x >>= 1;
  }
  return ret;
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  int tmp;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      scanf("%d", &tmp);
      if (tmp) {
        sta[i] = sta[i] | (1 << (j - 1));
        stt[j] = stt[j] | (1 << (i - 1));
      }
      mm[i][j] = tmp;
    }
  }
  int mi = 1000000000, mark;
  if (n > k) {
    int now;
    for (int i = 1; i <= n; i++) {
      now = i;
      int cou = 0;
      for (int j = 1; j <= n; j++) {
        int sta1 = sta[j];
        int sta2 = sta[j] ^ mark;
        int s1, s2;
        s1 = s2 = 0;
        for (int q = 1; q <= m; q++) {
          if (mm[j][q] == mm[now][q])
            s1++;
          else
            s2++;
        }
        cou += min(s1, s2);
      }
      mi = min(mi, cou);
    }
  } else {
    mark = (1 << n) - 1;
    for (int now = 0; now < (1 << n); now++) {
      int cou = 0;
      for (int i = 1; i <= m; i++) {
        int sta1 = stt[i];
        int sta2 = stt[i] ^ mark;
        int s1, s2;
        s1 = sta1 ^ now;
        s2 = sta2 ^ now;
        cou += min(cal(s1, n), cal(s2, n));
      }
      mi = min(mi, cou);
    }
  }
  if (mi > k)
    printf("-1\n");
  else
    printf("%d\n", mi);
  return 0;
}
