def shell_sort(lst: list):
    """Shell sort implementation."""
    counter = 0
    lst_copy = lst
    length = len(lst_copy)
    interval = length // 2
    while interval > 0:
        for i in range(interval, length):
            temp = lst_copy[i]
            j = i
            counter += 1
            while j >= interval and lst_copy[j-interval] > temp:
                if lst_copy[j-interval] > temp:
                    counter += 1
                    lst_copy[j], lst_copy[j -
                                          interval] = lst_copy[j-interval], lst_copy[j]
                    j -= interval
                else:
                    break

            lst_copy[j] = temp
        interval = interval // 2

    return counter