#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int grid[100][100];
int test(vector<int> &x) {
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    int diff = 0;
    for (int j = 0; j < m; ++j) {
      diff += grid[i][j] != x[j];
    }
    diff = min(diff, m - diff);
    ans += diff;
  }
  return ans;
}
int main() {
  cin >> n >> m >> k;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) cin >> grid[i][j];
  if (n <= 10) {
    for (int i = 0; i < 100; ++i)
      for (int j = 0; j < i; ++j) swap(grid[i][j], grid[j][i]);
    swap(n, m);
  }
  int ans = 11;
  if (m <= 10) {
    for (int i = 0; i < (1 << m); ++i) {
      int cpi = i;
      vector<int> x;
      for (int j = 0; j < m; ++j) {
        x.push_back(cpi % 2);
        cpi /= 2;
      }
      ans = min(ans, test(x));
    }
  } else {
    for (int i = 0; i < 11; ++i) {
      vector<int> x;
      for (int j = 0; j < m; ++j) x.push_back(grid[i][j]);
      ans = min(ans, test(x));
    }
  }
  if (ans > k)
    cout << "-1\n";
  else
    cout << ans << '\n';
}
