#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:600000000")
using namespace std;
template <class T>
T sqr(T x) {
  return x * x;
}
double const pi = 3.1415926535897932384626433832795;
int const inf = (int)1e9;
long long const inf64 = (long long)4e18;
const string name = "b";
const int NMAX = 101;
int n, m, k;
int a[NMAX][NMAX], b[NMAX][NMAX];
int solve(int msk) {
  int cnt = 0;
  for (int i = 0; i < (int)n; i++)
    for (int j = 0; j < (int)m; j++) b[i][j] = a[i][j];
  for (int i = 0; i < (int)m; i++)
    if (msk & (1 << i)) b[0][i] ^= 1, cnt++;
  for (int j = 0; j < (int)n; j++) {
    int now = 0;
    for (int f = 0; f < (int)m; f++)
      if (b[0][f] != b[j][f]) now++;
    cnt += min(now, m - now);
  }
  return cnt;
}
int main() {
  cin >> n >> m >> k;
  for (int i = 0; i < (int)n; i++)
    for (int j = 0; j < (int)m; j++) scanf("%d", &a[i][j]);
  if (n < m) {
    for (int i = 0; i < (int)m; i++)
      for (int j = 0; j < (int)m; j++)
        if (i < j) swap(a[i][j], a[j][i]);
    swap(n, m);
  }
  if (n > k) {
    int ans = k + 1;
    for (int i = 0; i < (int)n; i++) {
      int cnt = 0;
      for (int j = 0; j < (int)n; j++) {
        int now = 0;
        for (int f = 0; f < (int)m; f++)
          if (a[i][f] != a[j][f]) now++;
        cnt += min(now, m - now);
      }
      ans = min(ans, cnt);
    }
    if (ans > k)
      cout << -1 << endl;
    else
      cout << ans << endl;
    return 0;
  }
  int ans = k + 1;
  for (int i = 0; i < (int)1 << m; i++) {
    ans = min(ans, solve(i));
  }
  if (ans > k)
    cout << -1 << endl;
  else
    cout << ans << endl;
  return 0;
}
