#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, k, A[111][111];
  while (cin >> n >> m >> k) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        cin >> A[i][j];
      }
    }
    int best = numeric_limits<int>::max();
    if (n > 10 || m > 10) {
      for (int i = 0; i < n; i++) {
        int tblChanges = 0;
        for (int j = 0; j < n; j++) {
          int colChanges = 0;
          for (int k = 0; k < m; k++) {
            if (A[i][k] != A[j][k]) {
              colChanges++;
            }
          }
          tblChanges += min(colChanges, m - colChanges);
        }
        best = min(best, tblChanges);
      }
      for (int i = 0; i < m; i++) {
        int tblChanges = 0;
        for (int j = 0; j < m; j++) {
          int rowChanges = 0;
          for (int k = 0; k < n; k++) {
            if (A[k][i] != A[k][j]) {
              rowChanges++;
            }
          }
          tblChanges += min(rowChanges, n - rowChanges);
        }
        best = min(best, tblChanges);
      }
    } else {
      int to = 1 << m;
      for (int p = 0; p < to; p++) {
        for (int i = 0; i < n; i++) {
          int tblChanges = 0;
          for (int c = 0; c < n; c++) {
            if ((1 << c) & p) {
              A[i][c] = !A[i][c];
              tblChanges++;
            }
          }
          for (int j = 0; j < n; j++) {
            int colChanges = 0;
            for (int k = 0; k < m; k++) {
              if (A[i][k] != A[j][k]) {
                colChanges++;
              }
            }
            tblChanges += min(colChanges, m - colChanges);
          }
          best = min(best, tblChanges);
          for (int c = 0; c < n; c++) {
            if ((1 << c) & p) {
              A[i][c] = !A[i][c];
            }
          }
        }
      }
    }
    cout << ((best > k) ? -1 : best) << endl;
  }
  return 0;
}
