#include <bits/stdc++.h>
using namespace std;
void transpose(vector<vector<int>> &a) {
  vector<vector<int>> b(a[0].size(), vector<int>(a.size()));
  for (int i = 0; i < b.size(); i++) {
    for (int j = 0; j < b[i].size(); j++) {
      b[i][j] = a[j][i];
    }
  }
  a = b;
  return;
}
int solve(vector<vector<int>> &a, int ind) {
  int n = a.size(), m = a[0].size();
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int req1 = 0, req2 = 0;
    for (int j = 0; j < m; j++) {
      req1 += (a[ind][j] != a[i][j]);
      req2 += (a[ind][j] == a[i][j]);
    }
    ans += min(req1, req2);
  }
  return ans;
}
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  vector<vector<int>> a(n, vector<int>(m));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  int ans = k + 1;
  if (m <= k || n <= k) {
    if (n <= k) {
      transpose(a);
      swap(n, m);
    }
    for (int i = 0; i < (1 << m); i++) {
      int used = 0;
      for (int j = 0; j < m; j++) {
        if (i & (1 << j)) {
          a[0][j] = 1 - a[0][j];
          used++;
        }
      }
      int val = solve(a, 0);
      ans = min(ans, val + used);
      for (int j = 0; j < m; j++) {
        if (i & (1 << j)) {
          a[0][j] = 1 - a[0][j];
        }
      }
    }
  } else {
    for (int i = 0; i < n; i++) {
      ans = min(ans, solve(a, i));
    }
  }
  if (ans <= k) {
    cout << ans << endl;
  } else {
    cout << -1 << endl;
  }
  return 0;
}
