#include <bits/stdc++.h>
using namespace std;
struct entry {
  vector<int> Line;
  int changes;
  int line;
};
int main() {
  ios_base::sync_with_stdio(0);
  int n, m, k;
  cin >> n >> m >> k;
  vector<vector<int>> Table;
  if (n > m)
    Table = vector<vector<int>>(n, vector<int>(m));
  else
    Table = vector<vector<int>>(m, vector<int>(n));
  for (int y = 0; y < n; y++)
    for (int x = 0; x < m; x++)
      if (n > m)
        cin >> Table[y][x];
      else
        cin >> Table[x][y];
  if (n < m) swap(n, m);
  int best = -1;
  if (m <= k) {
    vector<int> Line(m);
    for (int yl = 0; yl < 1 << m; yl++) {
      int ylb = yl;
      int kb = 0;
      while (ylb > 0) {
        if (ylb % 2)
          Line[kb] = 1;
        else
          Line[kb] = 0;
        ylb /= 2;
        kb++;
      }
      int kleft = k;
      for (int y = 0; y < n; y++) {
        int dif = 0;
        for (int x = 0; x < m; x++)
          if (Line[x] != Table[y][x]) dif++;
        dif = min(dif, m - dif);
        kleft -= dif;
        if (kleft < best) break;
      }
      if (best < kleft) best = kleft;
    }
    if (best == -1)
      cout << best << endl;
    else
      cout << k - best << endl;
  } else {
    for (int ym = 0; ym < n; ym++) {
      int kleft = k;
      for (int y = 0; y < n; y++)
        if (y != ym) {
          int dif = 0;
          for (int x = 0; x < m; x++)
            if (Table[ym][x] != Table[y][x]) dif++;
          dif = min(dif, m - dif);
          kleft -= dif;
          if (kleft < best) break;
        }
      if (best < kleft) best = kleft;
    }
    if (best == -1)
      cout << best << endl;
    else
      cout << k - best << endl;
  }
}
