#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
const int RANDOM1 = chrono::high_resolution_clock::now().time_since_epoch().count();
struct chash {
    int operator()(int x) const { return hash<int>{}(x ^ RANDOM1); }
};
#define ll long long
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define deb(x) cout<<#x<<" : "<<x<<"\n";
#define debug(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\n";
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define all(a) (a).begin(),(a).end()
#define bs binary_search
#define sz size()
#define vi vector<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ld long double
#define clr fflush(stdout);
//#define clr cout.flush();
#define N 100001
#define fpr(i,a,b) for(int i=a;i<b;i++)
#define fdr(i,a,b) for(int i=a;i>b;i--)
#define repp(i,a,b,d) for(int i=a;i<b;i+=d)
#define repd(i,a,b,d) for(int i=a;i>b;i-=d)
#define LLMIN LLONG_MIN
#define LLMAX LLONG_MAX
#define AKASH_PATEL ios_base::sync_with_stdio(false);
#define SVNIT_SURAT cin.tie(NULL);cout.tie(NULL);
#define mset(x,a) memset(x,a,sizeof(x));
#define nl cout<<'\n';
#define print(c) cout<<c<<'\n';
#define setp(n) cout << fixed << setprecision(n)
#define take_arr(a,n) fpr(i,0,n) cin>>a[i];
#define print_arr(a,n) for(int i=0;i<n;i++) {cout<<a[i]<<" ";} cout<<'\n';
#define take_mat(mat,n,m) fpr(i,0,n) fpr(j,0,m) cin>>mat[i][j];
#define set_mat(mat,n,m,k) fpr(i,0,n) fpr(j,0,m) mat[i][j]=k;
#define print_mat(dist,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<dist[i][j]<<" ";}cout<<'\n';}
template< class T > bool inside(T a, T b, T c) { return a<=b && b<=c; }
int main()
{
    AKASH_PATEL;
    SVNIT_SURAT;
    ll h,w,k;
    cin>>h>>w>>k;
    ll c[h][w];
    int c1=0;
    fpr(i,0,h)
    {
        fpr(j,0,w)
        {
            char d;
            cin>>d;
            c[i][j]=d-'0';
            if(d=='1')
            {
                c1++;
            }
        }
    }
    //print_mat(c,h,w)
    ll lim=(1<<(h-1));
    int ans=INT_MAX;
    if(c1<=k)
    {
        ans=0;
        print(ans)
        return 0;
    }
    fpr(i,1,lim)
    {
        vector <int> v;
        fpr(j,0,h-1)
        {
            if(i&(1<<j))
            {
                v.pb(j+1);
            }
        }
        ll bnum[v.sz+1];
        int id=1,cnt=1;
        for(auto it:v)
        {
            while(id<=it)
            {
                bnum[id++]=cnt;
            }
            cnt++;
        }
        while(id<=h)
        {
            bnum[id++]=cnt;
        }
        ll sum[v.sz+2];
        mset(sum,0)
        int cut=0;
        int l=0,cur=-1,flag=0;
        vector <int> tmp;
        //deb(i)
//        fpr(p,1,h+1)
//        {
//            cout<<bnum[p]<<" ";
//        }
//        nl
        fpr(j,0,w)
        {
            fpr(p,0,h)
            {
                if(c[p][j])
                sum[bnum[p+1]]++;
            }
            //nl
            int f=0;
//            fpr(p,1,v.sz+2)
//            {
//                cout<<sum[p]<<" ";
//            }
//            nl
            fpr(p,1,v.sz+2)
            {
                if(sum[p]>k)
                {
                    tmp.push_back(j);
                    cur=j;
                    cut++;
                    f=1;
                    break;
                }
            }
            if(f)
            {

                j--;
                fpr(p,0,v.sz+2)
                {
                    sum[p]=0;
                }
                if(l==cur)
                {
                    flag=1;
                    break;
                }
                l=j;
            }
        }
        if(flag==0)
        {
            //deb("tmp")
            //print_arr(tmp,tmp.sz)
            //deb("v")
            //print_arr(v,v.sz)
            ans=min(ans,cut+(int)v.sz);
        }
    }
    print(ans)
    return 0;
}





Measured memory_bytes: 384