#include <bits/stdc++.h>
using namespace std;
int s[110][110], ss[110][110];
int a[110], b[110];
int n, m, p, ans;
int calc() {
  int i, k = 0;
  for (i = 0; i < m; i++) k += (a[i] != b[i]);
  return k;
}
void Solve() {
  int i, j, k, x, y;
  for (k = 0; k < n; k++) {
    int tmp = 0;
    for (i = 0; i < m; i++) a[i] = s[k][i];
    for (j = 0; j < n; j++) {
      for (i = 0; i < m; i++) b[i] = s[j][i];
      x = calc();
      for (i = 0; i < m; i++) b[i] = 1 - s[j][i];
      y = calc();
      tmp += (x < y ? x : y);
    }
    ans = (ans < tmp ? ans : tmp);
  }
}
void Rev() {
  int i, j;
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++) ss[j][n - i - 1] = s[i][j];
  swap(n, m);
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++) s[i][j] = ss[i][j];
}
void SOLVE() {
  int i, j, k, x, y;
  for (k = 0; k < (1 << m); k++) {
    int kk = k;
    for (i = 0; i < m; i++) a[i] = kk % 2, kk /= 2;
    int tmp = 0;
    for (j = 0; j < n; j++) {
      for (i = 0; i < m; i++) b[i] = s[j][i];
      x = calc();
      for (i = 0; i < m; i++) b[i] = 1 - s[j][i];
      y = calc();
      tmp += (x < y ? x : y);
    }
    ans = (ans < tmp ? ans : tmp);
  }
}
int main() {
  int i, j, k;
  scanf("%d %d %d", &n, &m, &p);
  for (i = 0; i < n; i++)
    for (j = 0; j < m; j++) scanf("%d", &s[i][j]);
  if (n < m) Rev();
  ans = p + 1;
  if (n > p)
    Solve();
  else
    SOLVE();
  if (ans > p)
    puts("-1");
  else
    printf("%d\n", ans);
  return 0;
}
