#include <bits/stdc++.h>
using namespace std;
const int maxn = 100 + 5;
int n, m, K, ans;
bool cell[maxn][maxn], mark[maxn][maxn];
bool a[maxn], b[maxn];
void go(int x) {
  if (x == n + 1) {
    for (int j = 1; j <= m; j++) {
      int cnt = 0;
      for (int i = 1; i <= n; i++) {
        if ((cell[i][j] ^ a[i]) == 0) cnt++;
      }
      if (cnt > n - cnt)
        b[j] = 0;
      else
        b[j] = 1;
    }
    int dif = 0;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        if (cell[i][j] != (a[i] ^ b[j])) dif++;
      }
    }
    ans = min(ans, dif);
    return;
  }
  a[x] = 1;
  go(x + 1);
  a[x] = 0;
  go(x + 1);
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n >> m >> K;
  ans = 999999999;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) cin >> cell[i][j];
  if (n > m) {
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++) mark[j][i] = cell[i][j];
    swap(n, m);
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++) cell[i][j] = mark[i][j];
  }
  if (n <= K)
    go(1);
  else {
    for (int i = 1; i <= n; i++) {
      int sum = 0;
      for (int j = 1; j <= n; j++) {
        int tmp = 0;
        for (int k = 1; k <= m; k++) tmp += (cell[i][k] != cell[j][k]);
        sum += min(tmp, m - tmp);
      }
      ans = min(ans, sum);
    }
  }
  if (ans <= K)
    cout << ans << endl;
  else
    cout << -1 << endl;
  return 0;
}
