#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int n,m,t,num[20],val[20],ans=1e9;
string s[20];

int main()
{
	cin>>n>>m>>t;
	rep(i,n) cin>>s[i];
	rep(i,1<<(n-1))
	{
		int res=__builtin_popcount(i);
		memset(num,0,sizeof(num));
		memset(val,0,sizeof(val));
		rep(j,n) rep(k,j) num[j]+=(int)((i&(1<<k))>0);
		rep(j,m)
		{
			rep(k,n) val[num[k]]+=(s[k][j]=='1');
			bool ok=true;
			rep(k,15)
			{
				if(val[k]>t)
				{
					ok=false;
					break;
				}
			}
			if(!ok)
			{
				res++;
				memset(val,0,sizeof(val));
				rep(k,n) val[num[k]]+=(s[k][j]=='1');
				ok=true;
				rep(k,15)
				{
					if(val[k]>t)
					{
						ok=false;
						break;
					}
				}
				if(!ok)
				{
					res=1e9;
					break;
				}
			}
		}
		ans=min(ans,res);
	}
	cout<<ans<<endl;
	return 0;
}