#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) 
{
    os << "{ ";
    for(auto& y : x) 
    {
        os << y << " ";
    }
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) 
{
    return os << "[" << p.ff << ", " << p.ss << "]";
}

ll gcd(ll a, ll b)
{
    if(b==0)
    {
        return a;
    }

    return gcd(b, a%b);
}

ll modexp(ll a, ll b, ll c)
{   
    a%=c;

    ll ans = 1;

    while(b)
    {
        if(b&1)
        {
            ans = (ans*a)%c;
        }

        a = (a*a)%c;
        b >>= 1;
    }

    return ans;
}

ll nxt()
{
    ll x;
    cin >> x;
    return x;
}

const ll L = 1e3+5;
const ll M = 1e1+5;

ll a[M][L];

void solve()
{
    ll h = nxt(), w = nxt(), k = nxt();

    for(ll i=0; i<h; i++)
    {
        string s;
        cin >> s;

        for(ll j=0; j<w; j++)
        {
            a[i][j] = s[j] - 48;
        }
    }

    h--;

    ll ans = 1e15;
    ll prev = 0;

    for(ll mask = 0; mask < (1LL << h); mask++)
    {
        vector <ll> hh;

        for(ll i = 0; i < h; i++)
        {
            if(mask & (1LL << i))
            {
                hh.pb(i);
            }
        }

        vector <ll> check = vector <ll> (sz(hh) + 5, 0);

        ll ini = sz(hh);

        bool take = true;

        for(ll i=0; i<w; i++)
        {
            bool has = false;
            ll p = 0;

            for(ll j=0; j<=h; j++)
            {
                check[p] += a[j][i];

                // cout << "#### " << p << " " << check[p] << endl;
                
                if(p < sz(hh) && j == hh[p])
                {
                    // cout << "#### " << mask << " " << i << " " << j << " " << p << endl;
                    p++;
                }
            }

            for(ll j: check)
            {
                if(j > k)
                {
                    has = true;
                    break;
                }
            }

            if(has)
            {
                // cout << "*** " << i << " " << prev << endl;

                if(i != prev)
                {
                    ini++;
                    i--;

                    check = vector <ll> (sz(check), 0);
                    prev = i+1;
                }

                else
                {
                    take = false;
                    break;
                }
            }
        }

        if(!take)
        {
            continue;
        }

        // cout << mask << " " << ans << " " << ini << endl;

        ans = min(ini, ans);
    }

    cout << ans << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    ll T = 1;
    // T = nxt();

    while(T--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 384