#include <bits/stdc++.h>
int min(int a, int b) {
  if (a < b) return a;
  return b;
}
int n, m, k;
int map[105][105];
int x[15], y[15];
int A = 1 << 29;
void dfs(int v) {
  if (v == n + 1) {
    int gt = 0;
    for (int i = 1; i <= n; i++) y[i] = map[i][1] ^ x[i], gt += x[i];
    for (int i = 2; i <= m; i++) {
      int t1 = 0, t2 = 0;
      for (int j = 1; j <= n; j++)
        if (map[j][i] != y[j])
          t1++;
        else
          t2++;
      gt += min(t1, t2);
    }
    A = min(A, gt);
    return;
  }
  x[v] = 1;
  dfs(v + 1);
  x[v] = 0;
  dfs(v + 1);
}
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) scanf("%d", &map[i][j]);
  if (n > k) {
    int ans = (1 << 29);
    for (int i = 1; i <= n; i++) {
      int gt = 0;
      for (int j = 1; j <= n; j++)
        if (i != j) {
          int t1 = 0, t2 = 0;
          for (int k = 1; k <= m; k++)
            if (map[i][k] != map[j][k])
              t1++;
            else
              t2++;
          gt += min(t1, t2);
        }
      ans = min(ans, gt);
    }
    if (ans <= k)
      printf("%d\n", ans);
    else
      printf("-1\n");
  } else {
    dfs(1);
    if (A <= k)
      printf("%d\n", A);
    else
      printf("-1\n");
  }
}
