#include <bits/stdc++.h>
int n, m, k, mod[108];
int a[108][108];
int main() {
  scanf("%d%d%d", &n, &m, &k);
  if (n < m) {
    std::swap(n, m);
    for (int j = (1); j <= (m); ++j)
      for (int i = (1); i <= (n); ++i) scanf("%d", &a[i][j]);
  } else
    for (int i = (1); i <= (n); ++i)
      for (int j = (1); j <= (m); ++j) scanf("%d", &a[i][j]);
  if (m > 10) {
    int ans = 10086;
    for (int model = (1); model <= (n); ++model) {
      int cans = 0;
      for (int i = (1); i <= (n); ++i) {
        int cc = 0;
        for (int j = (1); j <= (m); ++j)
          if (a[i][j] != a[model][j]) ++cc;
        cans += std::min(cc, m - cc);
      }
      if (cans < ans) ans = cans;
    }
    if (ans <= k)
      printf("%d\n", ans);
    else
      printf("-1\n");
  } else {
    int ts = (1 << m);
    int ans = 10086;
    for (int cs = (0); cs < (ts); ++cs) {
      for (int i = (1); i <= (m); ++i) mod[i] = ((cs >> (i - 1)) & 1);
      int cans = 0;
      for (int i = (1); i <= (n); ++i) {
        int cc = 0;
        for (int j = (1); j <= (m); ++j)
          if (a[i][j] != mod[j]) ++cc;
        cans += std::min(cc, m - cc);
      }
      if (cans < ans) ans = cans;
    }
    if (ans <= k)
      printf("%d\n", ans);
    else
      printf("-1\n");
  }
  return 0;
}
