#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int a[100][100], b[100], mn = 1000;
int calc(int row) {
  int c1 = 0, c2 = 0, tot = 0;
  for (int i = 0; i < n; i++) {
    c1 = c2 = 0;
    for (int j = 0; j < m; j++) {
      if (a[row][j] == a[i][j])
        c1++;
      else
        c2++;
    }
    tot += m - max(c1, c2);
  }
  return tot;
}
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 > k) {
    for (int i = 0; i < n; i++) {
      mn = min(mn, calc(i));
    }
  } else {
    for (int i = 0; i < (1 << n); i++) {
      for (int j = 0; j < n; j++) {
        if ((i & (1 << j)) > 0) {
          b[j] = 1;
        } else {
          b[j] = 0;
        }
      }
      int tot = 0;
      for (int j = 0; j < m; j++) {
        int c1 = 0, c2 = 0;
        for (int k = 0; k < n; k++) {
          if (b[k] == a[k][j])
            c1++;
          else
            c2++;
        }
        tot += n - max(c1, c2);
      }
      mn = min(mn, tot);
    }
  }
  if (mn <= k)
    cout << mn << "\n";
  else
    cout << -1 << "\n";
  return 0;
}
