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

import static java.lang.Math.*;

public class Main {
    static public class pair {
        int u;
        int idx;
        int val;

        public pair(int x, int i) {
            u = x;
            idx = i;
            val = -1;
        }
    }

    static public class trp implements Comparable<trp> {

        int idx;
        int val;

        public trp(int v, int i) {
            idx = i;
            val = v;
        }

        @Override
        public int compareTo(trp trp) {
            return idx - trp.idx;
        }
    }

    static int[] color;
    static ArrayList<pair>[] adj;
    static int[] Arrx, Arry;
    static int inf = (int) 1e9, n, w, h, x, y;
    static boolean[][] matrix;
    static int[][][] memo;

    public static int dp(int x, int y, int crit) {
        if (x >= h || y >= w)
            return (int) 1e8;
        if (x == h - 1 && y == w - 1) {
            return matrix[x][y] ? 0 : crit;
        }
        if (memo[crit][x][y] != -1)
            return memo[crit][x][y];
        int ans = Integer.MAX_VALUE;
        if (matrix[x][y]) {
            ans = min(ans, dp(x + 1, y, 1));
            ans = min(ans, dp(x, y + 1, 1));
        } else {
            ans = min(ans, crit + dp(x + 1, y, 0));
            ans = min(ans, crit + dp(x, y + 1, 0));
        }
        return memo[crit][x][y] = ans;
    }

    public static boolean isBadrome(String str) {
        for (int i = 0; i <= str.length() / 2; i++)
            if (str.charAt(i) != str.charAt(str.length() - 1 - i))
                return false;
        return true;


    }

    public static void main(String[] args) throws Exception {
//        Scanner sc = new Scanner("kitchen.in");
//        PrintWriter pw = new PrintWriter("kitchen.out");
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int k = sc.nextInt();
        boolean[][] matrix = new boolean[w][h];
        for (int i = 0; i < h; i++) {
            String str = sc.next();
            for (int j = 0; j < w; j++)
                matrix[j][i] = str.charAt(j) == '1';
        }
        int n = 1 << (h - 1);
        int ans = 1000000;
       out: while (--n >= 0) {
            int sofarans = Integer.bitCount(n);
            int[] Arr = new int[sofarans + 1];
            boolean flag=true;
          out2:  for (int i = 0; i < w; i++) {
                int c = 0;
                for (int j = h-1; j>= 0; j--) {
                    if ((n & (1 << j)) == 0) {
                        if (matrix[i][j])
                            Arr[c]++;
                    } else {
                        c++;
                        if (matrix[i][j])
                            Arr[c]++;
                    }
                }
                for (int ss : Arr) {
                    if (ss > k) {
                        sofarans++;
                        Arr = new int[Integer.bitCount(n) + 1];
                        if(flag) {
                            i--;
                            flag=false;
                        }else
                            continue out;
                        continue out2;
                    }
                }
                flag=true;
            }
            ans=min(ans, sofarans);
        }
        pw.println(ans);
            pw.close();
        }

        public static class Scanner {
            StringTokenizer st;
            BufferedReader br;

            public Scanner(InputStream s) {
                br = new BufferedReader(new InputStreamReader(s));
            }

            public Scanner(String s) throws FileNotFoundException {
                br = new BufferedReader(new FileReader(s));

            }

            public String next() throws IOException {
                while (st == null || !st.hasMoreTokens())
                    st = new StringTokenizer(br.readLine());
                return st.nextToken();
            }

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

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

            public String nextLine() throws IOException {
                return br.readLine();
            }

            public double nextDouble() throws IOException {
                String x = next();
                StringBuilder sb = new StringBuilder("0");
                double res = 0, f = 1;
                boolean dec = false, neg = false;
                int start = 0;
                if (x.charAt(0) == '-') {
                    neg = true;
                    start++;
                }
                for (int i = start; i < x.length(); i++)
                    if (x.charAt(i) == '.') {
                        res = Long.parseLong(sb.toString());
                        sb = new StringBuilder("0");
                        dec = true;
                    } else {
                        sb.append(x.charAt(i));
                        if (dec)
                            f *= 10;
                    }
                res += Long.parseLong(sb.toString()) / f;
                return res * (neg ? -1 : 1);
            }

            public boolean ready() throws IOException, IOException {
                return br.ready();
            }

        }
    }


Measured memory_bytes: 23124