#include <bits/stdc++.h>
using namespace std;
int n, m, k, a[110][110], ans = 2100000000;
int main() {
  scanf("%d%d%d", &n, &m, &k);
  if (n < m) {
    int t = n;
    n = m;
    m = t;
    for (int i = 1; i <= m; i++)
      for (int j = 1; j <= n; j++) scanf("%d", &a[j][i]);
  } else {
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= m; j++) scanf("%d", &a[i][j]);
  }
  if (m <= 10)
    for (int i = 0; i < (1 << m); i++) {
      int sum = 0;
      for (int j = 1; j <= n; j++) {
        int s1 = 0, s2 = 0;
        for (int l = 0; l < m; l++)
          if (a[j][l + 1] != ((i >> l) & 1))
            s1++;
          else
            s2++;
        sum += min(s1, s2);
      }
      ans = min(ans, sum);
    }
  else
    for (int i = 1; i <= n; i++) {
      int sum = 0;
      for (int j = 1; j <= n; j++) {
        int s1 = 0, s2 = 0;
        for (int l = 1; l <= m; l++)
          if (a[j][l] != a[i][l])
            s1++;
          else
            s2++;
        sum += min(s1, s2);
      }
      ans = min(ans, sum);
    }
  if (ans > k)
    printf("-1\n");
  else
    printf("%d\n", ans);
  return 0;
}
