#include <bits/stdc++.h>
using namespace std;
int n, m, k;
int t[100][100];
int ei[100], ej[100];
int tt[100][100];
int sol = 1000000000;
void comprueba() {
  int c = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      c += t[i][j] != tt[i][j];
      if (c > k) return;
    }
  }
  sol = min(sol, c);
}
int main() {
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> t[i][j];
  if (k < n and k < m) {
    for (int ifija = 0; ifija <= k; ifija++) {
      for (int jfija = 0; jfija <= k; jfija++) {
        ei[ifija] = 0;
        ej[jfija] = (ei[ifija] + t[ifija][jfija]) % 2;
        for (int d = 0; d < n; d++) ei[d] = (ej[jfija] + t[d][jfija]) % 2;
        for (int d = 0; d < m; d++) ej[d] = (ei[ifija] + t[ifija][d]) % 2;
        for (int i = 0; i < n; i++)
          for (int j = 0; j < m; j++) tt[i][j] = (ei[i] + ej[j]) % 2;
        comprueba();
      }
    }
    if (sol == 1000000000)
      cout << -1 << endl;
    else
      cout << sol << endl;
    exit(0);
  }
  if (k < n) {
    for (int cj = 0; cj < (1 << m); cj++) {
      for (int j = 0; j < m; j++) ej[j] = (cj >> j) & 1;
      int count = 0;
      for (int i = 0; i < n; i++) {
        int cou = 1000000000;
        for (int val = 0; val < 2; val++) {
          int couact = 0;
          for (int j = 0; j < m; j++)
            if ((val + ej[j]) % 2 != t[i][j]) couact++;
          cou = min(cou, couact);
        }
        count += cou;
      }
      if (count <= k) sol = min(sol, count);
    }
    if (sol == 1000000000)
      cout << -1 << endl;
    else
      cout << sol << endl;
    exit(0);
  }
  if (k < m) {
    for (int ci = 0; ci < (1 << n); ci++) {
      for (int i = 0; i < n; i++) ei[i] = (ci >> i) & 1;
      int count = 0;
      for (int j = 0; j < m; j++) {
        int cou = 1000000000;
        for (int val = 0; val < 2; val++) {
          int couact = 0;
          for (int i = 0; i < n; i++)
            if ((val + ei[i]) % 2 != t[i][j]) couact++;
          cou = min(cou, couact);
        }
        count += cou;
      }
      if (count <= k) sol = min(sol, count);
    }
    if (sol == 1000000000)
      cout << -1 << endl;
    else
      cout << sol << endl;
    exit(0);
  }
  for (int ci = 0; ci < (1 << n); ci++) {
    for (int cj = 0; cj < (1 << m); cj++) {
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
          int vi = 0;
          if (ci & (1 << i)) vi = 1;
          int vj = 0;
          if (cj & (1 << j)) vj = 1;
          tt[i][j] = (vi + vj) % 2;
        }
      }
      comprueba();
    }
  }
  if (sol == 1000000000)
    cout << -1 << endl;
  else
    cout << sol << endl;
}
