#include <bits/stdc++.h>
using namespace std;
const int maxN = 100 + 10;
int a[maxN][maxN], n, m, k;
int b[maxN][maxN];
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> a[i][j];
  int res = 2e9;
  if (n <= 10 && m <= 10) {
    for (int row = 0; row < (1 << m); row++) {
      for (int col = 0; col < (1 << n); col++) {
        int cost = 0;
        for (int j = 0; j < m; j++) b[0][j] = ((row >> j) & 1);
        for (int i = 1; i < n; i++) b[i][0] = ((col >> i) & 1);
        for (int i = 1; i < n; i++)
          for (int j = 1; j < m; j++) b[i][j] = b[0][j] ^ b[i][0] ^ b[0][0];
        for (int i = 0; i < n; i++)
          for (int j = 0; j < m; j++) cost += (a[i][j] != b[i][j]);
        res = min(res, cost);
      }
    }
    if (res > k) res = -1;
    cout << res << endl;
    return 0;
  }
  if (m > 10) {
    for (int fix = 0; fix < m; fix++) {
      int cost = 0;
      for (int col = 0; col < m; col++) {
        if (col == fix) continue;
        int dif = 0;
        for (int i = 0; i < n; i++) dif += (a[i][fix] != a[i][col]);
        cost += min(dif, n - dif);
      }
      res = min(res, cost);
    }
    if (res > k) res = -1;
    cout << res << endl;
    return 0;
  }
  if (n > 10) {
    for (int fix = 0; fix < n; fix++) {
      int cost = 0;
      for (int row = 0; row < n; row++) {
        if (row == fix) continue;
        int dif = 0;
        for (int i = 0; i < m; i++) dif += (a[fix][i] != a[row][i]);
        cost += min(dif, m - dif);
      }
      res = min(res, cost);
    }
    if (res > k) res = -1;
    cout << res << endl;
    return 0;
  }
  return 0;
}
