#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const int INF = 1e9;
const int N = 150010;
int n, m, s, k;
int a[110][110];
int main() {
  scanf("%d%d%d", &n, &m, &k);
  int s0 = 0, s1 = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf("%d", &a[i][j]);
      if (a[i][j] == 0)
        s0++;
      else
        s1++;
    }
  }
  int ans = min(s0, s1);
  int b[110], sum, tmp;
  memset(b, 0, sizeof(b));
  for (int i = 0; i < n; i++) {
    sum = 0, tmp = 0;
    for (int j = 0; j < m; j++) {
      b[j] = a[i][j];
    }
    for (int j = 0; j < n; j++) {
      if (j == i) continue;
      tmp = 0;
      for (int t = 0; t < m; t++) {
        if (a[j][t] != b[t]) tmp++;
      }
      tmp = min(tmp, m - tmp);
      sum += tmp;
    }
    ans = min(ans, sum);
  }
  memset(b, 0, sizeof(b));
  for (int j = 0; j < m; j++) {
    sum = 0, tmp = 0;
    for (int i = 0; i < n; i++) {
      b[i] = a[i][j];
    }
    for (int i = 0; i < m; i++) {
      if (i == j) continue;
      tmp = 0;
      for (int t = 0; t < n; t++) {
        if (a[t][i] != b[t]) tmp++;
      }
      tmp = min(tmp, n - tmp);
      sum += tmp;
    }
    ans = min(ans, sum);
  }
  if (ans > k)
    puts("-1");
  else
    printf("%d\n", ans);
  return 0;
}
