#include <bits/stdc++.h>
using namespace std;
int m, n, k, A[105][105];
int main() {
  int mn = 1e9, cnt, tt;
  cin >> m >> n >> k;
  for (int i = 0; i < m; ++i) {
    for (int j = 0; j < n; ++j) {
      cin >> A[i][j];
    }
  }
  if (m <= k) {
    for (int kk = 0; kk < (1 << m); ++kk) {
      vector<int> go;
      for (int j = 0; j < m; ++j) {
        go.push_back((kk & (1 << j)) ? 1 : 0);
      }
      tt = 0;
      for (int i = 0; i < n; ++i) {
        cnt = 0;
        for (int j = 0; j < m; ++j) {
          if (go[j] != A[j][i]) cnt++;
        }
        cnt = min(cnt, m - cnt);
        tt += cnt;
        if (tt > k) break;
      }
      mn = min(mn, tt);
    }
    if (mn > k)
      cout << -1;
    else
      cout << mn;
    return 0;
  } else {
    for (int kk = 0; kk < m; ++kk) {
      vector<int> go;
      for (int j = 0; j < n; ++j) {
        go.push_back(A[kk][j]);
      }
      tt = 0;
      for (int i = 0; i < m; ++i) {
        cnt = 0;
        for (int j = 0; j < n; ++j) {
          if (go[j] != A[i][j]) cnt++;
        }
        cnt = min(cnt, n - cnt);
        tt += cnt;
        if (tt > k) break;
      }
      mn = min(mn, tt);
    }
    if (mn > k)
      cout << -1;
    else
      cout << mn;
  }
}
