#include <bits/stdc++.h>
using namespace std;
int a[100][100];
int main() {
  int n, m, z, sum, sum2, ans = 1e9, temp;
  scanf("%d %d %d", &n, &m, &z);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) scanf("%d", &a[i][j]);
  if (n > 10)
    for (int i = 0; i < n; i++) {
      temp = 0;
      for (int j = 0; j < n; j++)
        if (i != j) {
          sum = sum2 = 0;
          for (int k = 0; k < m; k++) {
            sum += (a[i][k] == a[j][k]);
            sum2 += (a[i][k] != a[j][k]);
          }
          temp += min(sum, sum2);
        }
      ans = min(ans, temp);
    }
  else {
    for (int i = 0; i < 1 << n; i++) {
      temp = 0;
      for (int j = 0; j < m; j++) {
        sum = sum2 = 0;
        for (int k = 0; k < n; k++) {
          sum += (a[k][j] == ((i >> k) & 1));
          sum2 += (a[k][j] != ((i >> k) & 1));
        }
        temp += min(sum, sum2);
      }
      ans = min(ans, temp);
    }
  }
  printf("%d\n", ans > z ? -1 : ans);
  return 0;
}
