#include <bits/stdc++.h>
int n, m, k;
int rect[108][108];
int revd[108];
void revr(int r) {
  for (int i = 0; i < m; i++) rect[r][i] = 1 - rect[r][i];
}
void revc(int c) {
  for (int i = 0; i < n; i++) rect[i][c] = 1 - rect[i][c];
}
int gmin(int x, int y) {
  if (x > y) return y;
  return x;
}
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", &rect[i][j]);
    }
  }
  int sol = k + 1;
  if (n <= k) {
    for (int i = 0; i < (1 << n); i++) {
      for (int j = 0; j < n; j++) revd[j] = 0;
      for (int j = 0; j < n; j++)
        if ((1 << j) & i) {
          revr(j);
          revd[j] = 1;
        }
      int ksol = 0;
      for (int j = 0; j < m; j++) {
        int ones = 0;
        for (int x = 0; x < n; x++)
          if (rect[x][j]) ones++;
        ksol += gmin(ones, n - ones);
      }
      if (sol > ksol) sol = ksol;
      for (int j = 0; j < n; j++)
        if (revd[j]) revr(j);
    }
  } else {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) revd[j] = 0;
      for (int j = 0; j < m; j++) {
        if (rect[i][j]) {
          revd[j] = 1;
          revc(j);
        }
      }
      int ksol = 0;
      for (int j = 0; j < n; j++) {
        int ones = 0;
        for (int x = 0; x < m; x++)
          if (rect[j][x]) ones++;
        ksol += gmin(ones, m - ones);
      }
      if (sol > ksol) sol = ksol;
      for (int j = 0; j < m; j++)
        if (revd[j]) revc(j);
    }
  }
  if (sol > k) {
    printf("-1\n");
  } else {
    printf("%d\n", sol);
  }
  return 0;
}
