import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format, std.datetime;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long H, W, K;
    scan(H, W, K);
    auto S = new string[](H);
    foreach (i; 0 .. H)
        S[i] = sread();
    long ans = long.max;
    loop_split_row: foreach (uint split_row; 0 .. 1 << (H - 1))
    {
        long cnt = popcnt(split_row);
        long row = cnt + 1;
        auto sum = new long[][](row, W);
        loop_w: foreach (i; 0 .. W)
        {
            long j;
            foreach (k; 0 .. H)
            {
                // writefln("%010b %s %s", split_row & (1 << k), j, k);
                sum[j][i] += S[k][i] - '0';
                j += ((split_row & (1 << k)) != 0);
            }
            if (i == 0)
                continue loop_w;
            foreach (k; 0 .. row)
                if (K < sum[k][i])
                    continue loop_split_row;
            foreach (k; 0 .. row)
                if (K < sum[k][i] + sum[k][i - 1])
                {
                    // writeln(i);
                    cnt++;
                    continue loop_w;
                }
            foreach (k; 0 .. row)
                sum[k][i] += sum[k][i - 1];
        }
        // writefln("%010b %s %s", split_row, sum, cnt);
        ans = ans.min(cnt);
    }
    writeln(ans);
}
