#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int a[150][150];
int b[150];
int main() {
  int ans = 87;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) scanf("%d", &a[i][j]);
  if (n > 10) {
    for (int i = 0; i < n; i++) {
      int tans = 0;
      for (int i2 = 0; i2 < n; i2++) {
        int diff1 = 0, diff2 = 0;
        for (int j = 0; j < m; j++) {
          if (a[i][j] != a[i2][j])
            diff1++;
          else
            diff2++;
        }
        tans += min(diff1, diff2);
      }
      tans = tans <= k ? tans : 87;
      ans = min(ans, tans);
    }
    printf("%d\n", ans == 87 ? -1 : ans);
  } else {
    for (int x = 0; x < (1 << n); x++) {
      int tans = 0;
      int cnt = 0;
      int y = x;
      while (y > 0) {
        b[cnt++] = y % 2;
        y >>= 1;
      }
      for (int j = 0; j < m; j++) {
        int diff1 = 0, diff2 = 0;
        for (int i = 0; i < n; i++) {
          if (a[i][j] != b[i])
            diff1++;
          else
            diff2++;
        }
        tans += min(diff1, diff2);
      }
      tans = tans <= k ? tans : 87;
      ans = min(ans, tans);
    }
    printf("%d\n", ans == 87 ? -1 : ans);
  }
}
