#include <bits/stdc++.h>
using namespace std;
int a[101][101];
int b[101][101];
int dp1[101][2];
int main() {
  int n, m, K;
  scanf("%d%d%d", &n, &m, &K);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) scanf("%d", &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];
  }
  if (n > 10) {
    int ans = 0x3f3f3f3f;
    for (int i = 0; i < n; i++) {
      int res = 0;
      for (int j = 0; j < n; j++) {
        int same = 0;
        for (int k = 0; k < m; k++) same += (a[j][k] == a[i][k]);
        res += min(same, m - same);
      }
      ans = min(ans, res);
    }
    if (ans > K)
      puts("-1");
    else
      printf("%d\n", ans);
  } else {
    int ans = 0x3f3f3f3f;
    for (int i = 0; i < (1 << n); i++) {
      int bit[11] = {0};
      int temp = i;
      for (int j = 0; j < n; j++) bit[j] = temp % 2, temp >>= 1;
      int res = 0;
      for (int j = 0; j < n; j++)
        if (a[j][0] != bit[j]) res++;
      for (int j = 1; j < m; j++) {
        int same = 0;
        for (int k = 0; k < n; k++)
          if (a[k][j] == bit[k]) same++;
        if (same > n - same)
          res += n - same;
        else
          res += same;
      }
      ans = min(ans, res);
    }
    if (ans > K)
      puts("-1");
    else
      printf("%d\n", ans);
  }
}
