#include <bits/stdc++.h>
using namespace std;
const int N = 102;
int n, m, k, a[N][N];
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i <= n - 1; ++i)
    for (int j = 0; j <= m - 1; ++j) scanf("%d", &a[i][j]);
  int ans = 1000000000;
  if (n <= k) {
    for (int k = 0; k <= (1 << n) - 1; ++k) {
      int cost = 0;
      for (int j = 0; j <= m - 1; ++j) {
        int z = 0;
        for (int i = 0; i <= n - 1; ++i) z += a[i][j] == ((k & (1 << i)) > 0);
        cost += min(z, n - z);
      }
      ans = min(ans, cost);
    }
  } else {
    for (int k = 0; k <= n - 1; ++k) {
      int cost = 0;
      for (int i = 0; i <= n - 1; ++i) {
        int z = 0;
        for (int j = 0; j <= m - 1; ++j) z += a[i][j] == a[k][j];
        cost += min(z, m - z);
      }
      ans = min(ans, cost);
    }
  }
  cout << (ans > k ? -1 : ans);
}
