#include <bits/stdc++.h>
using namespace std;
int f[105][105], n, k, m, maxn, p[105], sum, ss, ans;
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) scanf("%d", &f[i][j]);
  if (m <= k && n <= k) {
    ans = k + 1;
    for (int ii = (1 << m) - 1; ii >= 0; ii--) {
      for (int i = 0; i < m; i++)
        if (ii & (1 << i))
          p[i] = 1;
        else
          p[i] = 0;
      sum = 0;
      for (int i = 0; i < n; i++) {
        ss = 0;
        for (int j = 0; j < m; j++)
          if (f[i][j] == p[j]) ss++;
        sum += min(ss, m - ss);
      }
      if (sum < ans) ans = sum;
    }
  } else if (n > k) {
    ans = k + 1;
    for (int ii = 0; ii < n; ii++) {
      sum = 0;
      for (int i = 0; i < n; i++) {
        ss = 0;
        for (int j = 0; j < m; j++)
          if (f[i][j] == f[ii][j]) ss++;
        sum += min(ss, m - ss);
      }
      if (sum < ans) ans = sum;
    }
  } else {
    ans = k + 1;
    for (int ii = 0; ii < m; ii++) {
      sum = 0;
      for (int i = 0; i < m; i++) {
        ss = 0;
        for (int j = 0; j < n; j++)
          if (f[j][i] == f[j][ii]) ss++;
        sum += min(ss, n - ss);
      }
      if (sum < ans) ans = sum;
    }
  }
  if (ans > k) ans = -1;
  printf("%d\n", ans);
  return 0;
}
