#include <bits/stdc++.h>
using namespace std;
int a[111][111], b[111][111], n, m, k, st[111];
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> a[i][j];
  if (n > m) {
    for (int i = 0; i < m; i++)
      for (int j = 0; j < n; j++) b[i][j] = a[j][i];
    swap(n, m);
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++) a[i][j] = b[i][j];
  }
  int ans = 111 * 111;
  if (m > 10) {
    for (int col = 0; col < m; col++) {
      int temp = 0;
      for (int j = 0; j < m; j++) {
        int same = 0, diff = 0;
        for (int i = 0; i < n; i++) {
          same += a[i][j] != a[i][col];
          diff += a[i][j] == a[i][col];
        }
        temp += min(same, diff);
      }
      if (temp <= k) ans = min(ans, temp);
    }
  } else {
    for (int bit = 0; bit < (1 << n); bit++) {
      for (int z = 0; z < n; z++) st[z] = bit & (1 << z) ? 1 : 0;
      int temp = 0;
      for (int j = 0; j < m; j++) {
        int same = 0, diff = 0;
        for (int i = 0; i < n; i++) {
          same += a[i][j] != st[i];
          diff += a[i][j] == st[i];
        }
        temp += min(same, diff);
      }
      if (temp <= k) ans = min(ans, temp);
    }
  }
  cout << (ans < 111 * 111 ? ans : -1) << endl;
  return 0;
}
