#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
const int maxm = 1e3 + 5;
const int mod = 1e9 + 7;
int a[101][101];
inline void solve() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) scanf("%d", &a[i][j]);
  }
  if (n <= k) {
    int ans = 1e9;
    for (int s = 0; s < (1 << n); s++) {
      int cnt = 0;
      for (int j = 0; j < m; j++) {
        int c0 = 0, c1 = 0;
        for (int i = 0; i < n; i++) {
          if (a[i][j] == ((s >> i) & 1))
            c0++;
          else
            c1++;
        }
        cnt += min(c0, c1);
      }
      ans = min(ans, cnt);
    }
    printf("%d\n", ans > k ? -1 : ans);
  } else {
    int ans = 1e9;
    for (int s = 0; s < n; s++) {
      int cnt = 0;
      for (int i = 0; i < n; i++) {
        int c0 = 0, c1 = 0;
        for (int j = 0; j < m; j++) {
          if (a[i][j] == a[s][j])
            c0++;
          else
            c1++;
        }
        cnt += min(c0, c1);
      }
      ans = min(ans, cnt);
    }
    printf("%d\n", ans > k ? -1 : ans);
  }
}
int main() {
  solve();
  return 0;
}
