#include <bits/stdc++.h>
using namespace std;
const int MAXINT = 0x6fffffff;
const long long MAXLONG = (long long)1 << 60;
const int MAXN = 105;
int arr[MAXN][MAXN];
int n, m, k;
int main() {
  while (scanf("%d %d %d", &n, &m, &k) != -1) {
    for (long long i = (0); i < (n); i += 1) {
      for (long long j = (0); j < (m); j += 1) {
        scanf("%d", &arr[i][j]);
      }
    }
    if (n < m) {
      for (long long i = (0); i < (n); i += 1) {
        for (long long j = (i + 1); j < (m); j += 1) {
          swap(arr[j][i], arr[i][j]);
        }
      }
      swap(n, m);
    }
    int res = k + 1;
    if (n <= k) {
      int mask = 1 << n;
      for (long long co = (0); co < (mask); co += 1) {
        int once = 0;
        for (long long co1 = (0); co1 < (m); co1 += 1) {
          int dif = 0;
          for (long long ro = (0); ro < (n); ro += 1) {
            int bit = (co >> ro) & 1;
            dif += arr[ro][co1] ^ bit;
          }
          dif = min(dif, n - dif);
          once += dif;
        }
        res = min(res, once);
      }
    } else {
      for (long long i = (0); i < (n); i += 1) {
        int once = 0;
        for (long long ro = (0); ro < (n); ro += 1) {
          if (ro == i) continue;
          int dif = 0;
          for (long long co = (0); co < (m); co += 1) {
            dif += arr[i][co] ^ arr[ro][co];
          }
          dif = min(dif, m - dif);
          once += dif;
        }
        res = min(res, once);
      }
    }
    if (res > k) {
      puts("-1");
    } else {
      printf("%d\n", res);
    }
  }
  return 0;
}
