#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef double dd;
const int N = 1e5+5;
const dd eps = 1e-8;
const int mod = 1e9+7;

int n,w,k,sta,num[1005],nowcnt,ans = INT_MAX;
char table[15][1005];

bool check(int now){
  int cnt = 0,id = 0;
  for(int i = 1;i <= n;i++){
    num[id] += table[i][now] == '1';
    if(num[id] > k) return true;
    if((sta>>(i-1))&1) id++;
  }
  return false;
}

int main(){
  ios::sync_with_stdio(false);
  // freopen("input.txt","r",stdin);
  cin>>n>>w>>k;
  for(int i = 1;i <= n;i++){
    for(int j = 1;j <= w;j++) cin>>table[i][j];
  }
  for(sta = 0;sta < (1<<n);sta++){
    memset(num,0,sizeof(num));
    nowcnt = __builtin_popcount(sta);
    bool done = true;
    for(int j = 1;j <= w;j++){
      if(check(j)){
	nowcnt++;
	memset(num,0,sizeof(num));
	done = !check(j);
      }
    }
    if(done) ans = min(ans,nowcnt);
  }
  cout<<ans<<endl;
  return 0;
}
