/* ****revpro**** */
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl     '\n'
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)    
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define mii      map<ll,ll>
using namespace std;

#define TIME        cerr << "\nTime elapsed: " << setprecision(5) <<1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define N  100005
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;  
#define ordered_set tree<double, null_type,less<double>, rb_tree_tag,tree_order_statistics_node_update> 
ll n,q;
vi a(N),seg(4*N),lazy(4*N,-1);
void updaterange(ll cur,ll st,ll end,ll l,ll r,ll val)
{
  if(lazy[cur]!=1e18)                                    /* 2-change */
  {
    seg[cur]=min(lazy[cur],seg[cur]);          /* 3-change */
    if(st!=end)
    {
      lazy[cur<<1]=min(lazy[cur],lazy[cur<<1]);            /* 4-change */
      lazy[(cur<<1)+1]=min(lazy[cur],lazy[cur<<1|1]);                   /* 5-change */
    }
    lazy[cur]=1e18;                                    /* 6-change */
  }
  if(st>end||st>r||end<l) return;
  if(l<=st&&end<=r)
  {
    seg[cur]=min(val,seg[cur]);              /* 7-change */
    if(st!=end)
    {
      lazy[(cur<<1)]=min(val,lazy[cur<<1]);                           /* 8-change */
      lazy[(cur<<1)+1]=min(val,lazy[cur<<1|1]);                         /* 9-change */
    }
    return;
  }
  ll mid=(st+end)>>1;
  updaterange((cur<<1),st,mid,l,r,val);
  updaterange((cur<<1)+1,mid+1,end,l,r,val);
  seg[cur]=min(seg[cur<<1],seg[(cur<<1)+1]);                  /* 10-change */
}
ll query(ll cur,ll st,ll end,ll l,ll r)
{
  if(st>end||st>r||end<l) return hell;
  if(lazy[cur]!=1e18)
  {
    seg[cur]=min(lazy[cur],seg[cur]);              /* 11-change */
    if(st!=end)
    {
      lazy[cur<<1]=min(lazy[cur],lazy[cur<<1]);            /* 4-change */
      lazy[(cur<<1)+1]=min(lazy[cur],lazy[cur<<1|1]);                    /* 13-change */
    }
    lazy[cur]=1e18;
  }
  if(st>=l&&end<=r) return seg[cur];
  ll mid=(st+end)>>1;
  ll ans1=query(cur<<1,st,mid,l,r);
  ll ans2=query((cur<<1)+1,mid+1,end,l,r);
  return min(ans1,ans2);                                 /* 14-change */
}
ll cnt[1005][15];
void solve()
{
  ll n,m,k;
  cin>>n>>m>>k;
  string s[n];
  rep(i,0,n) cin>>s[i];
  ll ans=hell;
  rep(mask,0,1<<(n-1)){
    ll b=0;
    rep(j,0,n-1) if(mask&(1<<(j)))b++;
    // cout<<"new"<<mask<<endl;
    rep(i,0,m+1) rep(j,0,b+1) cnt[i][j]=0;
    rep(i,0,m)
    {
      rep(j,0,b+1) cnt[i+1][j]=cnt[i][j];
      ll sum=0,cur=0;
      rep(j,0,n)
      {
        sum+=(s[j][i]=='1');
        if(mask&(1<<j))
        {
          cnt[i+1][cur]+=sum;
          sum=0;
          cur++;
        }
      }
      cnt[i+1][cur]+=sum;
    }
    // rep(i,0,m+1)
    // {
    //   rep(j,0,b+1)
    //   {
    //     cout<<cnt[i][j]<<' ';
    //   }
    //   cout<<endl;
    // }
    lazy.assign(4*N,1e18);
    seg.assign(4*N,hell);
    updaterange(1,0,m,0,0,b);
    updaterange(1,0,m,1,m,hell);
    // cout<<"update\n";
    rep(i,0,m)
    {
      ll lo=i,h1=m;
      while(lo<h1)
      {
        ll mid=(lo+h1+1)/2;
        ll f=1;
        rep(j,0,b+1) if(cnt[mid][j]-cnt[i][j]>k) f=0;
        if(f) lo=mid;
        else h1=mid-1;
      }
      // cout<<i<<' '<<lo<<' '<<query(1,0,m,i,i)<<endl;
      updaterange(1,0,m,i+1,lo,query(1,0,m,i,i)+1);
      if(lo==m)
        updaterange(1,0,m,lo,lo,query(1,0,m,i,i));
      // rep(j,0,m+1) cout<<query(1,0,m,j,j)<<' ';
      // cout<<endl;
    }
    ans=min(ans,query(1,0,m,m,m));
  }
  cout<<ans;
}
signed main()
{
  
    /***********************************/
    unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
    mt19937_64 generator (seed);
    /***********************************/
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS=1;
//  cin>>TESTS;
  while(TESTS--)
  {
    solve();
    
  }
  TIME
  return 0;
}

Measured memory_bytes: 7424