#include <bits/stdc++.h>
using namespace std;
int a[105][105];
int vis[105][105];
int n, m, k, ans;
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 (m <= k) {
    int minn = 1 << 30;
    for (int sta = 0; sta < (1 << m); sta++) {
      int ans = 0;
      for (int i = 1; i <= n; i++) {
        int num = 0;
        for (int j = 1; j <= m; j++)
          if (a[i][j] != ((sta >> (j - 1)) & 1)) {
            num++;
          }
        ans += min(num, m - num);
      }
      minn = min(minn, ans);
    }
    if (minn > k)
      puts("-1");
    else
      printf("%d\n", minn);
  } else {
    int minn = 1 << 30;
    for (int x = 1; x <= k + 1; x++) {
      int ans = 0;
      for (int j = 1; j <= m; j++)
        if (j != x) {
          int num = 0;
          for (int i = 1; i <= n; i++)
            if (a[i][j] != a[i][x]) num++;
          ans += min(num, n - num);
        }
      minn = min(minn, ans);
    }
    if (minn > k)
      puts("-1");
    else
      printf("%d\n", minn);
  }
  return 0;
}
