h, w = map(int, input().split())
kangaroo = [[x for x, c in enumerate(input()) if c == "#"] for _ in range(h)]
memo = dict()

positions_sublist = [(x,) for x in range(w - 1)]
positions_list = [(), *positions_sublist]
for cans in range(w // 2 + 1):
    positions_sublist = [(*prevs, prev, x) for *prevs, prev in positions_sublist for x in range(prev + 2, w - 1)]
    positions_list.extend(positions_sublist)


def covers_kangaroo(y, positions):
    return not (1 <= y < len(kangaroo)) or \
           all(all(x in positions or x - 1 in positions for x in kangaroo[y]) for y in range(y - 1, y + 1))


def stacks(new_pos, positions):
    return all(any(x in positions for x in range(x - 1, x + 2)) for x in new_pos)


def num_cans(y, positions):
    if y < 0:
        return 0
    if (y, positions) in memo:
        return memo[(y, positions)]
    ans = min((num_cans(y - 2, new_pos) + len(new_pos) for new_pos in positions_list
               if covers_kangaroo(y - 2, new_pos) and stacks(new_pos, positions)), default=1e10)
    memo[(y, positions)] = ans
    return ans


print(num_cans(h + 1, positions_list[-1]))
