def count_leading_empty_lines(cell):
    """Count the number of leading empty cells."""
    lines = cell.splitlines(keepends=True)
    if not lines:
        return 0
    for i, line in enumerate(lines):
        if line and not line.isspace():
            return i
    return len(lines)