#include <bits/stdc++.h>
using namespace std;
double EPS = 1e-9;
int INF = 2000000000;
long long LINF = 8000000000000000000LL;
const long long MOD = 1000000007LL;
double PI = acos(-1);
int dirx[8] = {-1, 0, 0, 1, -1, -1, 1, 1};
int diry[8] = {0, 1, -1, 0, -1, 1, -1, 1};
inline long long gcd(long long x, long long y) {
  if (y == 0)
    return x;
  else
    return gcd(y, x % y);
}
inline long long lcm(long long x, long long y) { return x * y / gcd(x, y); }
inline string itos(int a) {
  char x[100];
  sprintf(x, "%d", a);
  string s = x;
  return s;
}
inline int stoi(string a) {
  char x[100];
  int res;
  strcpy(x, a.c_str());
  sscanf(x, "%d", &res);
  return res;
}
inline string uppercs(string s) {
  int n = (int)s.size();
  for (int i = 0; i < n; i++)
    if (s[i] >= 'a' && s[i] <= 'z') s[i] = s[i] - 'a' + 'A';
  return s;
}
inline string lowercs(string s) {
  int n = (int)s.size();
  for (int i = 0; i < n; i++)
    if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
  return s;
}
inline void OPEN(string s) {
  freopen((s + ".in").c_str(), "r", stdin);
  freopen((s + ".out").c_str(), "w", stdin);
}
bool a[110][110];
int n, m, k, all;
int main() {
  cin >> m >> n >> k;
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      cin >> a[i][j];
    }
  }
  all = m * n;
  if (k < m) {
    for (int pi = 0; pi <= k; pi++) {
      int co = 0;
      for (int i = 0; i < m; i++) {
        int r = 0;
        for (int j = 0; j < n; j++) {
          r += a[pi][j] ^ a[i][j];
        }
        co += min(r, n - r);
      }
      all = min(all, co);
    }
  } else {
    for (int mk = 0; mk < 1 << m; mk++) {
      int co = 0;
      for (int j = 0; j < n; j++) {
        int c = 0;
        for (int i = 0; i < m; i++) {
          c += (mk >> i & 1) ^ a[i][j];
        }
        co += min(c, m - c);
      }
      all = min(all, co);
    }
  }
  if (all <= k)
    cout << all << endl;
  else
    cout << -1 << endl;
  return 0;
}
