#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int f, b[N], ans, mask, res, x, n, m, k, i, j, a[N][N];
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cin >> n >> m >> k;
  ans = k + 1;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) cin >> a[i][j];
  if (m <= 10) {
    for (mask = 0; mask < (1 << m); mask++) {
      res = 0;
      int x = mask;
      for (j = 1; j <= m; j++) {
        b[j] = x % 2;
        x /= 2;
      }
      for (i = 1; i <= n; i++) {
        x = 0;
        for (j = 1; j <= m; j++) x += (a[i][j] == b[j]);
        res += min(x, m - x);
        if (res > k) break;
      }
      ans = min(ans, res);
    }
  } else {
    for (f = 1; f <= n; f++) {
      res = 0;
      for (i = 1; i <= n; i++) {
        x = 0;
        for (j = 1; j <= m; j++) x += (a[i][j] == a[f][j]);
        res += min(x, m - x);
        if (res > k) break;
      }
      ans = min(ans, res);
    }
  }
  if (ans > k) ans = -1;
  cout << ans;
}
