def METHOD_NAME(line, line_num):
    '''
    parses lines of the form "# <title>", "## <sub title>", etc.
    if line is not a header, a regular string is returned.
    headers must contain exactly one space between the '#' and title, and may not contain trailing spaces.
    tabs are not friends.
    '''
    num_headers = 0
    for c in line:
        if c == '#':
            num_headers += 1
        else:
            break
    if num_headers == 0:
        return 0, line
    line = line[num_headers:]
    if line == "":
        raise MalformedHeaderError(line, line_num)
    if line[0] != " ":
        raise MalformedHeaderError(line, line_num)
    line = line[1:]
    if line.startswith(" ") or line.endswith(" "):
        raise MalformedHeaderError(line, line_num)
    return num_headers, line