#include <bits/stdc++.h>
using namespace std;
const int N = 109, inf = 0x7fffffff;
int a[N][N], cp[N][N];
int n, m, k;
int check(vector<int> &v, int l) {
  int r = 0;
  for (int i = 0; i < n; ++i) {
    if (i == l) continue;
    int t = 0;
    for (int j = 0; j < m; ++j) {
      if (a[i][j] == v[j]) t++;
    }
    r += min(t, m - t);
  }
  return r;
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) scanf("%d", &a[i][j]);
  if (n < m) {
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < m; ++j) {
        cp[j][i] = a[i][j];
      }
    swap(n, m);
    for (int i = 0; i < n; ++i)
      for (int j = 0; j < m; ++j) a[i][j] = cp[i][j];
  }
  int ans = inf;
  if (k < n) {
    for (int i = 0; i < n; ++i) {
      vector<int> v;
      for (int j = 0; j < m; ++j) v.push_back(a[i][j]);
      ans = min(ans, check(v, i));
    }
  } else {
    for (int i = 0; i < n; ++i) {
      for (int s = 0; s < (1 << m); ++s) {
        vector<int> v;
        int t = 0;
        for (int j = 0; j < m; ++j) {
          if (s & (1 << j))
            v.push_back(!a[i][j]), t++;
          else
            v.push_back(a[i][j]);
        }
        ans = min(ans, t + check(v, i));
      }
    }
  }
  if (ans > k) ans = -1;
  printf("%d\n", ans);
  return 0;
}
