output_description: Print the number of minimum times the bar needs to be cut so that every block
  after the cuts has K or less white squares.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      H W K
      S_{1,1}S_{1,2}...S_{1,W}
      :
      S_{H,1}S_{H,2}...S_{H,W}
attempt: #####
  
  import numpy as np
  from numpy import int32
  
  # from collections import Counter
  
  #####
  
  
  def getIntList(inp):
      return [int(_) for _ in inp]
  
  
  from sys import stdin
  import sys
  
  sys.setrecursionlimit(10**8)
  
  
  def getInputs():
      inputs = []
      for line in stdin:
          line = line.split()
          inputs.append(line)
      return inputs
  
  
  def main(inputs):
      h, w, k = getIntList(inputs[0])
  
      grid = np.empty((h, w), np.bool)
      for hi in range(h):
          grid[hi] = np.array([c == "1" for c in inputs[1 + hi][0]])
  
      # 	h=10
      # 	w=1000
      # 	k=10
      # 	grid=np.random.randint(0,2,(h,w))
  
      # 	print(grid.astype(int32))
      # 	print()
      # 	from matplotlib import pyplot as plt
      # 	plt.imshow(grid)
      # 	plt.show()
  
      divideHNum = 0
      mi = None
      for divideHNum in range(2 ** (h - 1)):
          divideH = np.empty(h + 1, np.bool)
          for hi in range(h):
              divideH[hi + 1] = divideHNum & (2**hi)
          divideH[0] = True
          divideH[-1] = True
          # 		print("divideH", divideHNum, divideH)
          indexH = np.where(divideH)[0]
          nums = np.empty((len(indexH) - 1, w), int32)
          for i, ih in enumerate(indexH[:-1]):
              nums[i] = grid[indexH[i] : indexH[i + 1]].sum(axis=0)
  
          # 		print(indexH)
          # 		print(nums)
          # 		print()
  
          cum = np.cumsum(nums, axis=1)
          # 		print(cum)
  
          divideW = 0
          divideWSize = 0
          prevNext = 0
          while divideW < w:
              next = np.where((cum[:, prevNext:] > k).any(axis=0))[0]
              # 			print("next",next)
              if len(next) == 0:
                  break
              next = next[0]
              if next == 0:
                  divideWSize = None
                  break
              next += prevNext
              divideWSize += 1
              cum -= cum[:, next - 1, None]
              prevNext = next
          # 			print("next",next)
          # 			print("cum",cum)
          # 		print("divideWSize",divideWSize)
          # 		print()
  
          if divideWSize is not None:
              divideSize = divideWSize + (len(indexH) - 2)
              if mi is None or divideSize < mi:
                  mi = divideSize
  
          divideHNum += 1
  
      print(mi)
  
  
  if __name__ == "__main__":
      inputs = getInputs()
      # 	inputs=simInputs()
      main(inputs)
  
problem_description: Statement
  
  We have a chocolate bar partitioned into H horizontal rows and W vertical
  columns of squares.
  
  The square (i, j) at the i-th row from the top and the j-th column from the
  left is dark if S_{i,j} is `0`, and white if S_{i,j} is `1`.
  
  We will cut the bar some number of times to divide it into some number of
  blocks. In each cut, we cut the whole bar by a line running along some
  boundaries of squares from end to end of the bar.
  
  How many times do we need to cut the bar so that every block after the cuts
  has K or less white squares?
samples: [{"input": "3 5 4\n    11100\n    10001\n    00111", "output": "2\n    \n\nFor example, cutting between the 1-st and 2-nd rows and between the 3-rd and\n4-th columns - as shown in the figure to the left - works.\n\nNote that we cannot cut the bar in the ways shown in the two figures to the\nright.\n\n![Figure](https://img.atcoder.jp/ghi/ac90dd542639c04402125403b1c319d7.png)\n\n* * *"}, {"input": "3 5 8\n    11100\n    10001\n    00111", "output": "0\n    \n\nNo cut is needed.\n\n* * *"}, {"input": "4 10 4\n    1110010010\n    1000101110\n    0011101001\n    1101000111", "output": "3"}]