#include <bits/stdc++.h>
using namespace std;
template <class T>
inline int maximize(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline int minimize(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const int N = 105, INF = 0x3f3f3f3f;
int a[N][N], b[N][N], n, m, k, s[N], ans = INF;
int check() {
  int ret = 0;
  for (int i = 1; i <= n; ++i) {
    int x = 0, y = 0;
    for (int j = 1; j <= m; ++j) {
      x += s[j] == a[i][j];
      y += s[j] != a[i][j];
    }
    ret += min(x, y);
  }
  return ret;
}
void dfs(int d) {
  if (d > m) {
    minimize(ans, check());
    return;
  }
  s[d] = 0;
  dfs(d + 1);
  s[d] = 1;
  dfs(d + 1);
}
int main() {
  cin >> n >> m >> k;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      cin >> b[i][j];
    }
  }
  if (n < m) {
    for (int i = 1; i <= n; ++i) {
      for (int j = 1; j <= m; ++j) {
        a[j][i] = b[i][j];
      }
    }
    swap(n, m);
  } else {
    for (int i = 1; i <= n; ++i) {
      for (int j = 1; j <= m; ++j) {
        a[i][j] = b[i][j];
      }
    }
  }
  if (n > k) {
    for (int i = 1; i <= n; ++i) {
      for (int j = 1; j <= m; ++j) s[j] = a[i][j];
      minimize(ans, check());
    }
  } else {
    dfs(1);
  }
  if (ans > k) ans = -1;
  cout << ans << endl;
  return 0;
}
