#include <bits/stdc++.h>
using namespace std;
const int N = 110, inf = 0x3f3f3f3f;
int T, n, m, k, ans = inf, cnt, a[N][N], s[N][N];
inline int read() {
  int sum = 0, fg = 1;
  char c;
  for (; c < '0' || c > '9'; c = getchar())
    if (c == '-') fg = -1;
  for (; c >= '0' && c <= '9'; c = getchar())
    sum = (sum << 3) + (sum << 1) + c - '0';
  return sum * fg;
}
inline void sol() {
  for (int l = 1; l <= k + 1; ++l) {
    int cnt = 0;
    for (int r = 1; r <= m; ++r) {
      int sum = 0;
      for (int i = 1; i <= n; ++i) sum += a[i][l] == a[i][r];
      cnt += min(sum, n - sum);
    }
    ans = min(ans, cnt);
  }
  return;
}
inline void calc(int cnt) {
  for (int d = 2; d <= n; ++d) {
    int sum = 0;
    for (int j = 1; j <= m; ++j) sum += a[1][j] == a[d][j];
    cnt += min(sum, m - sum);
  }
  ans = min(ans, cnt);
  return;
}
inline void dfs(int k, int sum) {
  if (k == m + 1) {
    calc(sum);
    return;
  }
  dfs(k + 1, sum);
  a[1][k] = !a[1][k];
  dfs(k + 1, sum + 1);
  a[1][k] = !a[1][k];
  return;
}
int main() {
  {
    n = read(), m = read(), k = read();
    ans = inf;
    for (int i = 1; i <= n; ++i)
      for (int j = 1; j <= m; ++j) a[i][j] = read();
    if (k < m)
      sol();
    else
      dfs(1, 0);
    if (ans > k)
      puts("-1");
    else
      printf("%d\n", ans);
  }
  return 0;
}
