#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <set>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <cmath>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <array>
#include <valarray>
#include <complex>
#include <random>
#include <functional>
#include <cassert>
#include <chrono>
#include <memory>

using namespace std;

#define int long long
//region TEMPLATE
////@formatter:off
#define double long double
typedef long long ll;
typedef unsigned long long ull;
template<typename T>void __read(T &a) { cin >> a; }
template<typename T, typename ... Args> void __read(T &a, Args &... args) { cin >> a;__read(args...);}
#define make(t, ...) t __VA_ARGS__; __read(__VA_ARGS__)
#define makev(a, n) VI a(n); FOR(n) cin >> a[i];
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FORIT(p) for(auto it = p.begin(); it != p.end(); it++)
#define FOR(b) for(signed i = 0; i <(b); i++)
#define FORE(i, l, r) for(int i = (l); i < (r); i++)
#define NFOR(i, n) for(int i = (((int) n)-1); i >= 0; i--)
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<pair<int, int>, int> PPII;
constexpr ll M7 = 1000000007ll;
constexpr ll M9 = 1000000009ll;
constexpr ll MFFT = 998244353ll;
template<class T> void outv(T &a) { for (auto &x : a) cout << x << ' '; }
static mt19937 rnd(static_cast<unsigned>(chrono::steady_clock::now().time_since_epoch().count())); // NOLINT(cert-err58-cpp)
auto __fast_io__ = (ios_base::sync_with_stdio(false), cin.tie(nullptr)); // NOLINT(cert-err58-cpp,cppcoreguidelines-interfaces-global-init)
////@formatter:on
//endregion


int32_t main() {
    make(int, n, m, k);
    vector<string> a(n);
    for(int i = 0; i < n; ++i){
        cin >> a[i];

    }
    int ans = n + m;
    VI cnt(1 << (n - 1));
    for(int mask = 0; mask < cnt.size(); ++mask){
        if (mask != 0){
            cnt[mask] = cnt[mask & (mask - 1)] + 1;
        }
        int sz = cnt[mask];
        VI q(sz + 1);
        int f = 0;
        for(int j = 0; j < m; ++j){
            int z = 0;
            q[z] += a[0][j] - '0';
            for(int i = 1; i < n; ++i){
                if ((mask >> (i - 1)) & 1){
                    z++;
                }
                q[z] += a[i][j] - '0';
            }
            bool ok = true;
            for(int i = 0; ok && i <= sz; ++i){
                ok = q[i] <= k;
            }
            if (!ok){
                fill(ALL(q), 0);
                f++;
                z = 0;
                q[z] += a[0][j] - '0';
                for(int i = 1; i < n; ++i){
                    if ((mask >> (i - 1)) & 1){
                        z++;
                    }
                    q[z] += a[i][j] - '0';
                }
            }
            ok = true;
            for(int i = 0; ok && i <= sz; ++i){
                ok = q[i] <= k;
            }
            if (!ok){
                f = n + m;
                break;
            }
        }
        ans = min(ans, f + sz);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256