#include <bits/stdc++.h>
using namespace std;
int A[210][210];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> A[i][j];
  int mini = k + 1;
  if (n <= k) {
    for (int i = 0; i < (1 << n); i++) {
      vector<int> rt;
      for (int j = 0; j < n; j++)
        if (i & (1 << j))
          rt.push_back(1);
        else
          rt.push_back(0);
      vector<int> gd;
      for (int p = 0; p < m; p++) {
        int ct1 = 0, ct2 = 0;
        for (int j = 0; j < n; j++) {
          if (A[j][p] ^ rt[j])
            ct1++;
          else
            ct2++;
        }
        if (ct1 > ct2)
          gd.push_back(1);
        else
          gd.push_back(0);
      }
      int ans = 0;
      for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++) {
          if (A[i][j] != rt[i] ^ gd[j]) ans++;
        }
      mini = min(mini, ans);
    }
    if (mini <= k)
      cout << mini << '\n';
    else
      cout << -1 << '\n';
  } else {
    for (int i = 0; i < n; i++) {
      vector<int> rt;
      for (int j = 0; j < m; j++) rt.push_back(A[i][j]);
      vector<int> gd;
      for (int p = 0; p < n; p++) {
        int ct1 = 0, ct2 = 0;
        for (int j = 0; j < m; j++) {
          if (A[p][j] ^ rt[j])
            ct1++;
          else
            ct2++;
        }
        if (ct1 > ct2)
          gd.push_back(1);
        else
          gd.push_back(0);
      }
      int ans = 0;
      for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++) {
          if (A[i][j] != rt[j] ^ gd[i]) ans++;
        }
      mini = min(mini, ans);
      rt.clear();
      gd.clear();
      for (int j = 0; j < m; j++) rt.push_back(1 - A[i][j]);
      for (int p = 0; p < n; p++) {
        int ct1 = 0, ct2 = 0;
        for (int j = 0; j < m; j++) {
          if (A[p][j] ^ rt[j])
            ct1++;
          else
            ct2++;
        }
        if (ct1 > ct2)
          gd.push_back(1);
        else
          gd.push_back(0);
      }
      ans = 0;
      for (int i = 0; i < n; i++)
        for (int j = 0; j < m; j++) {
          if (A[i][j] != rt[j] ^ gd[i]) ans++;
        }
      mini = min(mini, ans);
    }
    if (mini <= k)
      cout << mini << '\n';
    else
      cout << -1 << '\n';
  }
}
