#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-6;
const int MOD = 1e9 + 7;
const int MAXN = 110;
const double PI = acos(-1.0);
int ipt[MAXN][MAXN];
int main() {
  int n, m, k;
  while (~scanf("%d%d%d", &n, &m, &k)) {
    int ans = INF, all = 1 << m;
    for (int i = 0; i < (n); ++i)
      for (int j = 0; j < (m); ++j) scanf("%d", &ipt[i][j]);
    if (n < m) {
      for (int i = 0; i < (n); ++i)
        for (int j = (i + 1); j < (m); ++j) swap(ipt[i][j], ipt[j][i]);
      swap(n, m);
    }
    if (n > k) {
      for (int i = 0; i < (n); ++i) {
        int tans = 0;
        for (int j = 0; j < (n); ++j) {
          int cnt = 0;
          for (int k = 0; k < (m); ++k) cnt += ipt[i][k] ^ ipt[j][k];
          tans += min(cnt, m - cnt);
        }
        ans = min(ans, tans);
      }
    } else {
      for (int mask = 0; mask < all; mask++) {
        int tans = 0;
        for (int i = 0; i < (n); ++i) {
          int cnt = 0;
          for (int j = 0; j < (m); ++j) cnt += ipt[i][j] ^ (mask >> j & 1);
          tans += min(cnt, m - cnt);
        }
        ans = min(ans, tans);
      }
    }
    printf("%d\n", ans <= k ? ans : -1);
  }
  return 0;
}
