#include <bits/stdc++.h>
using namespace std;
const int N = 100;
int a[N][N], b[N][N];
int main() {
  int n, m, k;
  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 < n; i++)
      for (int j = 0; j < m; j++) b[j][i] = a[i][j];
    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 = k + 1;
  if (m <= k) {
    for (int i = 0; i < (1 << n); i++) {
      int now = 0;
      for (int j = 0; j < m; j++) {
        int f1 = 0, f2 = 0;
        for (int k = 0; k < n; k++) {
          if (a[k][j] == (bool)(i & (1 << k)))
            f1++;
          else
            f2++;
        }
        now += min(f1, f2);
      }
      ans = min(ans, now);
    }
  } else {
    for (int i = 0; i < m; i++) {
      int now = 0;
      for (int j = 0; j < m; j++) {
        int f1 = 0, f2 = 0;
        for (int k = 0; k < n; k++)
          if (a[k][j] == a[k][i])
            f1++;
          else
            f2++;
        now += min(f1, f2);
      }
      ans = min(ans, now);
    }
  }
  cout << (ans <= k ? ans : -1) << endl;
  return 0;
}
