#include <bits/stdc++.h>
using namespace std;
int a[110][110], b[110][110];
int main() {
  int n, m, k;
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) scanf("%d", &b[i][j]);
  if (n > m) {
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++) a[j][i] = b[i][j];
    swap(n, m);
  } else {
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++) a[i][j] = b[i][j];
  }
  int ans = 1e9;
  if (m > k) {
    for (int cl = 0; cl < m; cl++) {
      int sum = 0;
      for (int i = 0; i < m; i++) {
        if (i == cl) continue;
        int tmp = 0;
        for (int j = 0; j < n; j++) {
          if (a[j][i] == a[j][cl]) tmp++;
        }
        sum += min(tmp, n - tmp);
      }
      ans = min(ans, sum);
    }
  } else {
    int top = 1 << m;
    for (int it = 0; it < top; it++) {
      int sum = 0;
      for (int i = 0; i < m; i++) {
        if (it & (1 << i)) {
          sum++;
          a[0][i] ^= 1;
        }
      }
      for (int i = 1; i < n; i++) {
        int tmp = 0;
        for (int j = 0; j < m; j++) {
          if (a[i][j] == a[0][j]) tmp++;
        }
        sum += min(tmp, m - tmp);
      }
      ans = min(ans, sum);
      for (int i = 0; i < m; i++) {
        if (it & (1 << i)) {
          a[0][i] ^= 1;
        }
      }
    }
  }
  printf("%d\n", ans <= k ? ans : -1);
  return 0;
}
