#include <bits/stdc++.h>
using namespace std;
template <class T>
T abs(T x) {
  return x > 0 ? x : -x;
}
int n;
int m;
int k;
int u[100];
int a[100][100];
int main() {
  scanf("%d %d %d", &n, &m, &k);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j) scanf("%d", a[i] + j);
  int ans = 1e9;
  if (n > k) {
    for (int r = 0; r < n; ++r) {
      int cur = 0;
      for (int i = 0; i < n; ++i) {
        int cnt = 0;
        for (int j = 0; j < m; ++j) cnt += int(a[i][j] == a[r][j]);
        cur += min(cnt, m - cnt);
      }
      ans = min(ans, cur);
    }
  } else {
    for (int mask = 0; mask < (1 << n); ++mask) {
      for (int i = 0; i < n; ++i)
        if ((mask >> i) & 1)
          for (int j = 0; j < m; ++j) u[j] = a[i][j];
      bool can = true;
      for (int i = 0; i < n; ++i)
        if ((mask >> i) & 1)
          for (int j = 0; j < m; ++j)
            if (u[j] != a[i][j]) can = false;
      if (can) {
        int cur = 0;
        for (int i = 0; i < n; ++i)
          if ((mask >> i) ^ 1) {
            int cnt = 0;
            for (int j = 0; j < m; ++j) cnt += int(a[i][j] == u[j]);
            cur += min(cnt, m - cnt);
          }
        ans = min(ans, cur);
      }
    }
  }
  if (m > k) {
    for (int c = 0; c < m; ++c) {
      int cur = 0;
      for (int j = 0; j < m; ++j) {
        int cnt = 0;
        for (int i = 0; i < n; ++i) cnt += int(a[i][j] == a[i][c]);
        cur += min(cnt, n - cnt);
      }
      ans = min(ans, cur);
    }
  } else {
    for (int mask = 0; mask < (1 << m); ++mask) {
      for (int j = 0; j < m; ++j)
        if ((mask >> j) & 1)
          for (int i = 0; i < n; ++i) u[i] = a[i][j];
      bool can = true;
      for (int j = 0; j < m; ++j)
        if ((mask >> j) & 1)
          for (int i = 0; i < n; ++i)
            if (u[i] != a[i][j]) can = false;
      if (can) {
        int cur = 0;
        for (int j = 0; j < m; ++j)
          if ((mask >> j) ^ 1) {
            int cnt = 0;
            for (int i = 0; i < n; ++i) cnt += int(a[i][j] == u[i]);
            cur += min(cnt, n - cnt);
          }
        ans = min(ans, cur);
      }
    }
  }
  if (ans > k) ans = -1;
  printf("%d\n", ans);
  return 0;
}
