#include <bits/stdc++.h>
using namespace std;
int a[1111][1111];
int n, m, k;
inline void minimize(int &x, const int &y) {
  if (x > y) x = y;
}
void init(void) {
  scanf("%d%d%d", &m, &n, &k);
  for (int i = 0; i < (m); i = i + 1)
    for (int j = 0; j < (n); j = j + 1) scanf("%d", &a[i][j]);
}
int mindiff(int x, int y) {
  int res1 = 0;
  int res2 = 0;
  for (int i = 0; i < (m); i = i + 1)
    if (a[i][x] != a[i][y])
      res1++;
    else
      res2++;
  return (min(res1, res2));
}
int minstt(int x, int s) {
  int res1 = 0;
  int res2 = 0;
  for (int i = 0; i < (n); i = i + 1)
    if (a[x][i] ^ ((s >> i) & 1))
      res1++;
    else
      res2++;
  return (min(res1, res2));
}
void bigcase(void) {
  int res = k + 1;
  for (int i = 0; i < (n); i = i + 1) {
    int sum = 0;
    for (int j = 0; j < (n); j = j + 1) sum += mindiff(i, j);
    minimize(res, sum);
  }
  printf("%d", res > k ? -1 : res);
}
void smallcase(void) {
  int res = k + 1;
  for (int i = 0; i < (1 << n); i = i + 1) {
    int sum = 0;
    for (int j = 0; j < (m); j = j + 1) sum += minstt(j, i);
    minimize(res, sum);
  }
  printf("%d", res > k ? -1 : res);
}
int main(void) {
  init();
  if (n <= k)
    smallcase();
  else
    bigcase();
  return 0;
}
