#include <bits/stdc++.h>
using namespace std;
int A[105][105];
int B[105][105];
int main() {
  int N, M, K;
  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]);
  int ans = 1000000000;
  if (N > 10 && M > 10) {
    for (int r = 0; r < N; r++) {
      vector<int> pillars;
      pillars.push_back(-1);
      for (int i = 0; i < M - 1; i++)
        if (A[r][i] != A[r][i + 1]) pillars.push_back(i);
      pillars.push_back(M - 1);
      int count = 0;
      for (int x = 0; x < N; x++) {
        int temp1 = 0;
        for (int i = 0; i < pillars.size() - 1; i++) {
          int L = pillars[i] + 1, R = pillars[i + 1];
          int c0 = 0, c1 = 0;
          for (int j = L; j <= R; j++)
            if (A[x][j] == 0)
              c0++;
            else
              c1++;
          if (i % 2 == 0)
            temp1 += c0;
          else
            temp1 += c1;
        }
        count += min(temp1, M - temp1);
      }
      ans = min(ans, count);
    }
  } else {
    if (N <= 10) {
      for (int i = 0; i < N; i++)
        for (int j = 0; j < M; j++) B[i][j] = A[i][j];
      for (int i = 0; i < N; i++)
        for (int j = 0; j < M; j++) A[j][i] = B[i][j];
      swap(N, M);
    }
    for (int mask = 0; mask < (1 << (M - 1)); mask++) {
      vector<int> pillars;
      pillars.push_back(-1);
      for (int i = 0; i < M - 1; i++) {
        if ((mask & (1 << i)) > 0) pillars.push_back(i);
      }
      pillars.push_back(M - 1);
      int count = 0;
      for (int x = 0; x < N; x++) {
        int temp1 = 0;
        for (int i = 0; i < pillars.size() - 1; i++) {
          int L = pillars[i] + 1, R = pillars[i + 1];
          int c0 = 0, c1 = 0;
          for (int j = L; j <= R; j++)
            if (A[x][j] == 0)
              c0++;
            else
              c1++;
          if (i % 2 == 0)
            temp1 += c0;
          else
            temp1 += c1;
        }
        count += min(temp1, M - temp1);
      }
      ans = min(ans, count);
    }
  }
  if (ans > K) ans = -1;
  printf("%d\n", ans);
  return 0;
}
