#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool chkmin(T &a, const T &b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T>
inline bool chkmax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
const int INF = 0x3f3f3f3f;
const long long MOD = 1e9 + 7;
template <class T>
inline bool RD(T &ret) {
  char c;
  int sgn;
  if (c = getchar(), c == EOF) return 0;
  while (c != '-' && (c < '0' || c > '9')) c = getchar();
  sgn = (c == '-') ? -1 : 1, ret = (c == '-') ? 0 : (c - '0');
  while (c = getchar(), c >= '0' && c <= '9') ret = ret * 10 + (c - '0');
  ret *= sgn;
  return 1;
}
template <class T>
inline void PT(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) PT(x / 10);
  putchar(x % 10 + '0');
}
const int N = 123;
int n, m, K;
int mp[N][N];
int main() {
  RD(n), RD(m), RD(K);
  int sum = 0;
  for (int i = (0), i_end_ = (n); i < i_end_; ++i)
    for (int j = (0), j_end_ = (m); j < j_end_; ++j)
      RD(mp[i][j]), sum += mp[i][j];
  if (n == m && min(sum, n * m - sum) == n) {
    if (n <= K)
      return printf("%d\n", n), 0;
    else
      return puts("-1"), 0;
  }
  int ans = INF;
  for (int k = (0), k_end_ = (n); k < k_end_; ++k) {
    int tmp = 0;
    for (int i = (0), i_end_ = (n); i < i_end_; ++i) {
      int c = 0;
      for (int j = (0), j_end_ = (m); j < j_end_; ++j)
        if (mp[i][j] == mp[k][j]) c++;
      tmp += min(c, m - c);
    }
    ans = min(ans, tmp);
  }
  for (int k = (0), k_end_ = (m); k < k_end_; ++k) {
    int tmp = 0;
    for (int j = (0), j_end_ = (m); j < j_end_; ++j) {
      int c = 0;
      for (int i = (0), i_end_ = (n); i < i_end_; ++i)
        if (mp[i][j] == mp[i][k]) c++;
      tmp += min(c, n - c);
    }
    ans = min(ans, tmp);
  }
  if (ans > K)
    puts("-1");
  else
    cout << ans << endl;
}
