#include <bits/stdc++.h>
using namespace std;
int arr[110][110];
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", &arr[i][j]);
  int mi = 100000;
  if (n > k) {
    for (int i = 0; i < k + 1; i++) {
      int sum = 0;
      for (int j = 0; j < n; j++) {
        int cnt1 = 0, cnt2 = 0;
        for (int k = 0; k < m; k++) {
          if (arr[i][k] == arr[j][k])
            cnt1++;
          else
            cnt2++;
        }
        sum += min(m - cnt1, m - cnt2);
      }
      mi = min(mi, sum);
    }
  } else {
    int lim = 1 << n;
    for (int t = 0; t < lim; t++) {
      int sum = 0;
      for (int j = 0; j < m; j++) {
        int cnt1 = 0, cnt2 = 0;
        for (int k = 0; k < n; k++) {
          if (((t & (1 << k)) > 0) == arr[k][j])
            cnt1++;
          else
            cnt2++;
        }
        sum += min(n - cnt1, n - cnt2);
      }
      mi = min(mi, sum);
    }
  }
  printf("%d\n", (mi <= k) ? mi : -1);
}
