#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const int INF = 2e9;
const long long INF64 = 3e18;
const long double EPS = 1e-12;
const long double PI = 3.1415926535897932384620;
const long long MD = 925262732;
const long long T = 634521;
const int N = 300100;
const int M = 5001;
int n, m, k, a[101][101];
int main() {
  cin >> n >> m >> k;
  for (int i = 0; i < int(n); i++)
    for (int j = 0; j < int(m); j++) scanf("%d", &a[i][j]);
  int ans = INF;
  if (n <= k) {
    for (int mask = 0; mask < (1 << n); mask++) {
      int sum = 0;
      for (int j = 0; j < m; j++) {
        int s0 = 0, s1 = 0;
        for (int i = 0; i < n; i++) {
          if ((0 ^ bool(mask & (1 << i))) != a[i][j]) s0++;
          if ((1 ^ bool(mask & (1 << i))) != a[i][j]) s1++;
        }
        sum += min(s0, s1);
      }
      if (sum <= k) ans = min(ans, sum);
    }
  } else {
    for (int mask = 0; mask < n; mask++) {
      int sum = 0;
      for (int i = 0; i < n; i++) {
        int s0 = 0, s1 = 0;
        for (int j = 0; j < m; j++) {
          if (0 ^ a[mask][j] != a[i][j]) s0++;
          if (1 ^ a[mask][j] != a[i][j]) s1++;
        }
        sum += min(s0, s1);
      }
      if (sum <= k) ans = min(ans, sum);
    }
  }
  if (ans == INF)
    cout << -1;
  else
    cout << ans;
  return 0;
}
