#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 7;
int n, m, k, ans = 100, val[106];
int c[106][106], tmp[106][106];
int main() {
  cin >> n >> m >> k;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) cin >> c[i][j];
  }
  if (n < m) {
    for (int j = 0; j < m; j++)
      for (int i = 0; i < n; i++) tmp[j][i] = c[i][j];
    swap(n, m);
    for (int i = 0; i < n; i++)
      for (int j = 0; j <= m; j++) c[i][j] = tmp[i][j];
  }
  if (n > 10) {
    int ans = 100;
    for (int it = 0; it < n; it++) {
      int now = 0;
      for (int i = 0; i < n; i++) {
        int tmp1 = 0, tmp2 = 0;
        for (int j = 0; j < m; j++) {
          tmp1 += (c[i][j] == c[it][j]);
          tmp2 += (c[i][j] != c[it][j]);
        }
        now += min(tmp1, tmp2);
      }
      ans = min(ans, now);
    }
    printf("%d\n", ans > k ? -1 : ans);
  } else {
    int ans = 100;
    for (int st = 0; st < (1 << m); st++) {
      for (int i = 0; i < m; i++) {
        val[i] = ((st & (1 << i)) > 0);
      }
      int now = 0;
      for (int i = 0; i < n; i++) {
        int tmp1 = 0, tmp2 = 0;
        for (int j = 0; j < m; j++) {
          tmp1 += (c[i][j] == val[j]);
          tmp2 += (c[i][j] != val[j]);
        }
        now += min(tmp1, tmp2);
      }
      ans = min(ans, now);
    }
    printf("%d\n", ans > k ? -1 : ans);
  }
  return 0;
}
