#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
int n, m, k, ans;
int g[N][N];
int main() {
  ios::sync_with_stdio(false);
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) scanf("%d", &g[i][j]);
  int ans = 0x7ffffff;
  if (k < n) {
    for (int i = 0; i < n; i++) {
      int now = 0;
      for (int j = 0; j < n; j++) {
        int sum = 0;
        for (int k = 0; k < m; k++) {
          sum += (g[i][k] == g[j][k]);
        }
        now += min(sum, m - sum);
      }
      if (now < ans) ans = now;
    }
  } else {
    for (int i = 0; i < (1 << n); i++) {
      int now = 0;
      for (int j = 0; j < m; j++) {
        int sum = 0;
        for (int k = 0; k < n; k++) {
          sum += (g[k][j] == ((i >> k) & 1));
        }
        now += min(n - sum, sum);
      }
      if (now < ans) ans = now;
    }
  }
  if (ans <= k)
    printf("%d\n", ans);
  else
    puts("-1");
  return 0;
}
