#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

int h,w,k;
string ss[15];
int cnt[15];
int z;
int ro = 0;

int checkCut(int jj){
	int cc= 0;
	int ro = 0;

	for(int i =0;i<h;i++){
		//update cnt of row
			cnt[ro] += ss[i][jj] == '1';

		//check if need to cut
		if(cnt[ro] > k){
			cc = 1;
		}

		//adjust for horiontal cut already 
		if(z>>i & 1){
			ro ++;
		}
	}

	return cc;
}

int main(){
	int ans = 1e9;
	cin>>h>>w>>k;
	for(int i =0;i<h;i++){
		cin>>ss[i];
	}

	//bitmask for horizontal cuts
	//001 means cut on the third
	//100 means cut on the first
	for(z = 0;z< 1<<(h-1);z++){
		memset(cnt, 0, sizeof(cnt));
		int tot = __builtin_popcount(z);
		int re = 0;

		for(int j =0;j<w;j++){
			//if no of 1s>k 
			if(checkCut(j)){

				memset(cnt, 0, sizeof(cnt));
				tot ++;
				//?
				re = checkCut(j);
			}

		}

		//why !re when re == 0
		//else means no need vertical cut
		if(!re) ans= min(ans,tot);
	}

	cout<<ans;
}