#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int a[105][105];
int ans = 1e9;
int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      scanf("%d", &a[i][j]);
    }
  }
  if (n < m) {
    int tempa[105][105];
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        tempa[j][i] = a[i][j];
      }
    }
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= m; j++) {
        a[j][i] = tempa[j][i];
      }
    }
    swap(n, m);
  }
  if (m <= k) {
    int dd[11];
    for (int tt = 0; tt < (1 << m); tt++) {
      for (int j = 0; j < m; j++) {
        dd[j + 1] = (tt >> j) & 1;
      }
      int sum = 0;
      for (int j = 1; j <= n; j++) {
        int temp = 0;
        for (int k = 1; k <= m; k++) temp += dd[k] ^ a[j][k];
        if (temp <= m / 2)
          sum += temp;
        else
          sum += m - temp;
        if (sum > k) break;
      }
      if (sum > k)
        continue;
      else
        ans = min(ans, sum);
    }
  } else {
    for (int i = 1; i <= n; i++) {
      int sum = 0;
      for (int j = 1; j <= n; j++) {
        int temp = 0;
        for (int k = 1; k <= m; k++) temp += a[i][k] ^ a[j][k];
        if (temp <= m / 2)
          sum += temp;
        else
          sum += m - temp;
        if (sum > k) break;
      }
      if (sum > k)
        continue;
      else
        ans = min(ans, sum);
    }
  }
  if (ans == 1e9) ans = -1;
  printf("%d\n", ans);
  return 0;
}
