#include <bits/stdc++.h>
using namespace std;
int a[150][150], b[150][150];
int n, m, t, ans = 0x3f3f3f;
void solve() {
  if (n > t) {
    int output = 0x3f3f3f;
    for (int k = 1; k <= n; k++) {
      int sum = 0;
      for (int i = 1; i <= n; i++) {
        int cnt = 0, cnt2 = 0;
        for (int j = 1; j <= m; j++)
          if (a[i][j] != a[k][j]) cnt++;
        for (int j = 1; j <= m; j++)
          if (a[i][j] == a[k][j]) cnt2++;
        sum += min(cnt, cnt2);
      }
      output = min(output, sum);
    }
    ans = min(ans, output);
  } else if (m <= t) {
    int output = 0x3f3f3f3f;
    for (int k = 0; k < (1 << t); k++) {
      int sum = 0;
      for (int i = 2; i <= n; i++) {
        int cnt = 0, cnt2 = 0;
        for (int j = 1; j <= m; j++) {
          if ((k & (1 << (j - 1)))) {
            if (a[i][j] == a[1][j]) cnt++;
          } else if (a[i][j] != a[1][j])
            cnt++;
        }
        for (int j = 1; j <= m; j++) {
          if ((k & (1 << (j - 1)))) {
            if (a[i][j] != a[1][j]) cnt2++;
          } else if (a[i][j] == a[1][j])
            cnt2++;
        }
        sum += min(cnt, cnt2);
      }
      int ext = 0;
      for (int j = 1; j <= m; j++) {
        if ((k & (1 << (j - 1)))) ext++;
      }
      output = min(output, sum + ext);
    }
    ans = min(ans, output);
  }
}
int main() {
  scanf("%d%d%d", &n, &m, &t);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      scanf("%d", &a[i][j]);
      b[j][i] = a[i][j];
    }
  solve();
  memcpy(a, b, sizeof(a));
  swap(n, m);
  solve();
  if (ans <= t)
    printf("%d", ans);
  else
    printf("-1");
}
