#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
const int mod = 998244353;
int a[15][maxn];
int main() {
  int n, m, k;
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) scanf("%1d", &a[i][j]);
  int ans = 1e9;
  for (int i = 0; i < 1 << (n - 1); i++) {
    vector<int> R;
    int now = 0;
    R.push_back(0);
    for (int j = 1; j < n; j++)
      if (i & 1 << j - 1) R.push_back(j);
    R.push_back(n);
    now += R.size() - 2;
    vector<int> cnt(R.size() - 1, 0);
    int isok;
    for (int j = 1; j <= m; j++) {
      isok = 1;
      vector<int> cnt1(R.size() - 1, 0);
      for (int s = 0; s < R.size() - 1; s++) {
        for (int l = R[s] + 1; l <= R[s + 1]; l++)
          if (a[l][j] & 1) cnt1[s]++;
        if (cnt1[s] > k) {
          isok = -1;
          break;
        } else if (cnt1[s] + cnt[s] > k)
          isok = 0;
      }
      if (isok == -1)
        break;
      else if (isok == 1)
        for (int l = 0; l < R.size() - 1; l++) cnt[l] += cnt1[l];
      else
        now++, cnt = cnt1;
    }
    if (isok != -1) ans = min(ans, now);
  }
  cout << ans << endl;
  return 0;
}
