import java.util.*;
import java.io.*;

public class Main {

    private final static int MOD = (int)1e9 + 7;
    private static final int INF = (int)1e9;
    private int H, W, K;
    char[][] A;

    public Main(FastScanner in, PrintWriter out) {
        H = in.nextInt();
        W = in.nextInt();
        K = in.nextInt();
        A = new char[H][W];
        for (int i = 0; i < H; i++) {
            A[i] = in.next().toCharArray();
        }

        int res = 2000;
        for (int hc = 0; hc < 1 << (H - 1); hc++) {
            int nhcut = Integer.bitCount(hc);
            int[] cnt = new int[nhcut + 1];
            int nvcut = 0;
            boolean valid = true;
            for (int j = 0; j < W; j++) {
                // if col j needs to be in a new cut
                if (newCut(j, hc, cnt)) {
                    // starts a new cut
                    Arrays.fill(cnt, 0);
                    // if it still needs to be in a new cut
                    // horizontal cut is not good
                    if (newCut(j, hc, cnt)) {
                        valid = false;
                        break;
                    } else
                        nvcut++;
                }
            }
            if (valid)
                res = Math.min(res, nhcut + nvcut);
        }
        out.println(res);
    }
    // return true if we need to start a new cut from col j
    private boolean newCut(int j, int hcut, int[] cnt) {
        int rid = 0; // horizontal cut grp id
        for (int i = 0; i < H; i++) {
            if (A[i][j] == '1') cnt[rid]++;
            if (cnt[rid] > K) return true; // need to have a new cut
            // there is a cut here, move to the next horizontal cut
            if (((1 << i) & hcut) != 0) rid++;
        }
        return false;
    }

    private int gcd(int a, int b) {
        while (true) {
            if (b == 0) return a;
            int tmp = a;
            a = b;
            b = tmp % b;
        }
    }

    private long powm(long x, long p) {
        long res = 1;
        while (p > 0) {
            if (p % 2 == 1)
                res = res * x % MOD;
            x = x * x % MOD;
            p /= 2;
        }
        return res;
    }


    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        // Scanner in = new Scanner(
                // new BufferedReader(new InputStreamReader(System.in)));
        FastScanner in = new FastScanner(System.in);

        Main sol = new Main(in, out);

        out.close();
    }
}


class FastScanner{
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;

    public FastScanner(InputStream stream)
    {
        this.stream = stream;
    }

    int read()
    {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars){
            curChar = 0;
            try{
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    boolean isSpaceChar(int c)
    {
        return c==' '||c=='\n'||c=='\r'||c=='\t'||c==-1;
    }

    boolean isEndline(int c)
    {
        return c=='\n'||c=='\r'||c==-1;
    }

    int nextInt()
    {
        return Integer.parseInt(next());
    }

    long nextLong()
    {
        return Long.parseLong(next());
    }

    double nextDouble()
    {
        return Double.parseDouble(next());
    }

    String next(){
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do{
            res.appendCodePoint(c);
            c = read();
        }while(!isSpaceChar(c));
        return res.toString();
    }

    String nextLine(){
        int c = read();
        while (isEndline(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do{
            res.appendCodePoint(c);
            c = read();
        }while(!isEndline(c));
        return res.toString();
    }
}


Measured memory_bytes: 33548