#pragma GCC target ("avx")
#pragma GCC optimize ("unroll-loops")

#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)

int H, W, K;
string S[10];

signed main(){
	cin >> H >> W >> K;
	rep(i, H) cin >> S[i];

	int ans = INT_MAX;
	rep(i, 1<<H-1){
		int tmp = 0;
		rep(j, 10) tmp += (i>>j)&1;

		int cnt[10] ={};
		int flg = 0;
		rep(j, W){
			int idx = 0;
			rep(k, H){
				if(S[k][j] == '1') cnt[idx]++;
				idx += (i>>k)&1;
			}
			rep(k, H){
				if(cnt[k] > K){
					if(flg == 1){
						flg = 2;
						break;
					}
					memset(cnt, 0, sizeof(cnt));
					tmp++;
					j--;
					flg = 1;
					break;
				}
				if(k == H-1) flg = 0;
			}
			if(flg == 2){
				tmp = INT_MAX;
				break;
			}
		}

		ans = min(ans, tmp);
	}
	cout << ans << endl;
}

/*
2 2 1
11
11
*/