#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  vector<vector<int>> matrix(n, vector<int>(m));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      cin >> matrix[i][j];
    }
  }
  int result = numeric_limits<int>::max();
  if (m <= k) {
    int maskEnd = 1 << m;
    for (int mask = 0; mask < maskEnd; ++mask) {
      int cur = 0;
      for (int i = 0; i < n; ++i) {
        int t = 0;
        for (int j = 0, x = mask; j < m; ++j) {
          if ((x & 1) == matrix[i][j]) ++t;
          x >>= 1;
        }
        cur += min(t, m - t);
      }
      result = min(result, cur);
    }
  } else {
    for (int fixj = 0; fixj < m; ++fixj) {
      int cur = 0;
      for (int j = 0; j < m; ++j) {
        if (j == fixj) continue;
        int t = 0;
        for (int i = 0; i < n; ++i) {
          if (matrix[i][j] == matrix[i][fixj]) ++t;
        }
        cur += min(t, n - t);
      }
      result = min(result, cur);
    }
  }
  if (result > k) result = -1;
  cout << result << endl;
  return 0;
}
