#include <bits/stdc++.h>
using namespace std;

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) begin(x), end(x)
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

template<typename T>
struct cumulative_sum_2d {
    int h, w;
    T zero;
    std::vector<std::vector<T>> data;
    template<typename I> cumulative_sum_2d(I begin, I end, T zero = T())
        : h(end - begin), w(begin->end() - begin->begin()), zero(zero), data(h + 1, std::vector<T>(w + 1, zero)) {
        for (auto itr_y = begin, itr_data = data.begin() + 1; itr_y != end; itr_y++, itr_data++) {
            std::copy(itr_y->begin(), itr_y->end(), itr_data->begin() + 1);
        }
        for (int i = 1; i <= h; i++) {
            for (int j = 0; j < w; j++) { data[i][j + 1] += data[i][j]; }
        }
        for (int i = 0; i < h; i++) {
            for (int j = 1; j <= w; j++) { data[i + 1][j] += data[i][j]; }
        }
    }
    T get_sum(int y0, int x0, int y1, int x1) const {
        if (y0 >= y1 || y0 > h || y1 < 0) { return zero; }
        if (y0 < 0) { y0 = 0; }
        if (y1 > h) { y1 = h; }
        if (x0 >= x1 || x0 > w || x1 < 0) { return zero; }
        if (x0 < 0) { x0 = 0; }
        if (x1 > w) { x1 = w; }
        return data[y1][x1] - data[y1][x0] - data[y0][x1] + data[y0][x0];
    }
};

int H, W, K;
string S[11];
signed main() {
    cin >> H >> W >> K;
    vvint a(H, vint(W));
    rep(i, H) {
        cin >> S[i];
        rep(j, W) {
            a[i][j] = S[i][j] - '0';
        }
    }
    cumulative_sum_2d<int> cs(all(a));
    int ans = LLONG_MAX;
    rep(i, bit(H - 1)) {
        int cur = 0;
        rep(j, H - 1) {
            cur += (i >> j) & 1;
        }
        int l = 0;
        rep(j, W) {
            int sc = 0;
            rep(k, H) {
                if ((i >> (k - 1)) & 1) { sc = 0; }
                sc += cs.get_sum(k, j, k + 1, j + 1);
                if (sc > K) { goto label; }
            }
            int s = 0;
            rep(k, H) {
                if ((i >> (k - 1)) & 1) { s = 0; }
                s += cs.get_sum(k, l, k + 1, j + 1);
                if (s > K) {
                    l = j, cur++;
                    break;
                }
            }
        }
        chmin(ans, cur);
        label:;
    }
    cout << ans << endl;
}


Measured memory_bytes: 512