#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  vector<vector<int>> a(n, vector<int>(m));
  int ans = 1e9;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> a[i][j];
  if (n <= k) {
    for (int msk = 0; msk < (1 << n); msk++) {
      vector<int> x;
      for (int i = 0; i < n; i++) {
        int b = (msk >> i) & 1;
        x.push_back(b);
      }
      vector<int> y(m);
      for (int j = 0; j < m; j++) {
        int cur = 0;
        for (int i = 0; i < n; i++) {
          if (a[i][j] == x[i]) cur++;
        }
        if (cur > n - cur)
          y[j] = 0;
        else
          y[j] = 1;
      }
      int sum = 0;
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
          int b = x[i] ^ y[j];
          if (a[i][j] != b) sum++;
        }
      }
      if (sum <= k) ans = min(ans, sum);
    }
  } else {
    for (int h = 0; h < m; h++) {
      vector<int> x;
      for (int j = 0; j < n; j++) x.push_back(a[j][h]);
      vector<int> y(m);
      for (int j = 0; j < m; j++) {
        int cur = 0;
        for (int i = 0; i < n; i++) {
          if (a[i][j] == x[i]) cur++;
        }
        if (cur > n - cur)
          y[j] = 0;
        else
          y[j] = 1;
      }
      int sum = 0;
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
          int b = x[i] ^ y[j];
          if (a[i][j] != b) sum++;
        }
      }
      if (sum <= k) ans = min(ans, sum);
    }
  }
  if (ans == 1e9)
    cout << -1;
  else
    cout << ans;
  return 0;
}
