#include <bits/stdc++.h>
int t[10000];
int main() {
  int n, m, k;
  std::cin >> n >> m >> k;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      std::cin >> t[100 * i + j];
    }
  }
  int ans = 1000000;
  if (n > k) {
    for (int j = 0; j < n; j++) {
      int dc = 0;
      for (int j2 = 0; j2 < m; j2++) {
        int c = 0;
        for (int i = 0; i < n; i++) {
          if (t[100 * i + j] == t[100 * i + j2]) c++;
        }
        dc += std::min(c, n - c);
      }
      ans = std::min(ans, dc);
    }
  } else {
    for (int j = 0; j < (1 << n); j++) {
      int dc = 0;
      for (int j2 = 0; j2 < m; j2++) {
        int c = 0;
        for (int i = 0; i < n; i++) {
          if (((int)(bool)(j & (1 << i))) == t[100 * i + j2]) c++;
        }
        dc += std::min(c, n - c);
      }
      ans = std::min(ans, dc);
    }
  }
  if (ans > k) {
    std::cout << -1;
  } else {
    std::cout << ans;
  }
}
