#include <bits/stdc++.h>
using namespace std;
const int MAXN = 105;
const int INF = 1 << 30;
int a[MAXN][MAXN], A[MAXN][MAXN], val[MAXN], n, m, k;
int main() {
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      scanf("%d", &A[i][j]);
    }
  }
  if (n < m) {
    for (int i = 1; i <= n; ++i) {
      for (int j = 1; j <= m; ++j) {
        a[j][i] = A[i][j];
      }
    }
    swap(n, m);
  } else {
    for (int i = 1; i <= n; ++i) {
      for (int j = 1; j <= m; ++j) {
        a[i][j] = A[i][j];
      }
    }
  }
  if (n > 10) {
    int ans = INF;
    for (int it = 1; it <= n; ++it) {
      int now = 0;
      for (int i = 1; i <= n; ++i) {
        int temp1 = 0, temp2 = 0;
        for (int j = 1; j <= m; ++j) {
          temp1 += a[i][j] == a[it][j];
          temp2 += a[i][j] != a[it][j];
        }
        now += min(temp1, temp2);
      }
      ans = min(ans, now);
    }
    printf("%d\n", ans <= k ? ans : -1);
  } else {
    int ans = INF;
    for (int st = 0; st < (1 << m); ++st) {
      for (int i = 0; i < m; ++i) {
        val[i] = !!(st & (1 << i));
      }
      int now = 0;
      for (int i = 1; i <= n; ++i) {
        int temp1 = 0, temp2 = 0;
        for (int j = 1; j <= m; ++j) {
          temp1 += a[i][j] == val[j];
          temp2 += a[i][j] != val[j];
        }
        now += min(temp1, temp2);
      }
      ans = min(ans, now);
    }
    printf("%d\n", ans <= k ? ans : -1);
  }
  return 0;
}
