#include <bits/stdc++.h>
using namespace std;
int main() {
  int h, w, k;
  scanf("%i%i%i", &h, &w, &k);
  vector<vector<char>> arr(h, vector<char>(w));
  for (auto &x : arr)
    for (auto &y : x) scanf(" %c", &y);
  int _max = 1 << (h - 1);
  int ans = INT_MAX;
  vector<int> par_map(h);
  vector<int> sum(h);
  for (int x = 0; x < _max; x++) {
    par_map[0] = 0;
    fill(sum.begin(), sum.end(), 0);
    int cur = 0;
    for (int y = 0; y < h - 1; y++) {
      if (x >> y & 1)
        par_map[y + 1] = y + 1, cur++;
      else
        par_map[y + 1] = par_map[y];
    }
    for (int z = 0; z < w; z++) {
      bool _passed = false;
      for (int y = 0; y < h; y++) {
        if (arr[y][z] == '1') {
          sum[par_map[y]]++;
          _passed |= sum[par_map[y]] > k;
        }
      }
      if (_passed) {
        cur++;
        for (int y = 0; y < h; y++) sum[y] = 0;
        for (int y = 0; y < h; y++) sum[par_map[y]] += (arr[y][z] == '1');
      }
    }
    ans = min(ans, cur);
  }
  printf("%i\n", ans);
}
