open System
open System.Numerics

// prelude
let readStr () = stdin.ReadLine()

let readInt () = stdin.ReadLine() |> int
let readInts () = stdin.ReadLine().Split() |> Array.map int

let pair = function
| [|a; b|] -> (a, b)
| _ -> failwith "owatta"

let triple = function
| [|a; b; c|] -> (a, b, c)
| _ -> failwith "owatta"

let inc n = n + 1
let dec n = n - 1

module Array =
  let modify (arr: _ []) i f =
    arr.[i] <- f arr.[i]
  let scan (arr: _ []) fold state =
    let mutable acc = state
    let dest = Array.zeroCreate arr.Length
    for i in 0..(arr.Length-1) do
      acc <- fold acc arr.[i]
      dest.[i] <- acc
    dest

// start

let rec popCnt = function
| 0 -> 0
| n -> (if (n &&& 1) <> 0 then 1 else 0) + popCnt (n>>>1)

let main () =
  let (H, W, K) = readInts() |> triple

  let grid =
    let g = Array2D.create H W 0
    for y in 0..(H-1) do
      let s = readStr().ToCharArray()
      for x in 0..(W-1) do
        g.[y, x] <- if s.[x] = '1' then 1 else 0
    g

  seq {
    for split in 0..((1<<<H-1)-1) do
      let mutable cnt = popCnt split
      let sum = Array.create 10 0

      let add x =
        let mutable i = 0
        for y in 0..(H-1) do
          Array.modify sum i ((+) grid.[y, x])
          if (split &&& (1<<<y)) <> 0 then do
            i <- i + 1

      for x in 0..(W-1) do
        add x
        if sum |> Array.exists (fun s -> s > K) then do
          cnt <- cnt + 1
          Array.fill sum 0 10 0
          add x
      
      yield cnt
  }
  |> Seq.min
  |> printfn "%A"

main()