#include <bits/stdc++.h>
using namespace std;
int num[105][105], n, m, k, ans;
int get1(int a) {
  int res = 0;
  for (int i = 1; i <= n; i++) {
    if (i != a) {
      int res1 = 0, res2 = 0;
      for (int j = 1; j <= m; j++) {
        if (num[i][j] != num[a][j]) res1++;
        if (num[i][j] == num[a][j]) res2++;
      }
      res += min(res1, res2);
    }
  }
  return res;
}
int main() {
  ans = (1e8 + 7);
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) scanf("%d", &num[i][j]);
  if (n > k) {
    for (int i = 1; i <= n; i++) ans = min(ans, get1(i));
  } else {
    for (int i = 0; i < (1 << n); i++) {
      int res1 = 0, res2 = 0, res = 0;
      for (int j = 1; j <= n; j++) {
        if ((num[j][1] && (i & (1 << (j - 1)))) ||
            (!num[j][1] && !(i & (1 << (j - 1)))))
          res1++;
        else
          res2++;
      }
      res += min(res1, res2);
      for (int j = 2; j <= m; j++) {
        res1 = 0, res2 = 0;
        for (int k = 1; k <= n; k++) {
          if ((num[k][j] && (i & (1 << (k - 1)))) ||
              (!num[k][j] && !(i & (1 << (k - 1)))))
            res1++;
          else
            res2++;
        }
        res += min(res1, res2);
      }
      ans = min(ans, res);
    }
  }
  if (ans > k)
    printf("-1\n");
  else
    printf("%d\n", ans);
  return 0;
}
