def min_distance(index1: int, index2: int) -> int:
        # if first word index is overflow - delete all from the second word
        if index1 >= len_word1:
            return len_word2 - index2
        # if second word index is overflow - delete all from the first word
        if index2 >= len_word2:
            return len_word1 - index1
        diff = int(word1[index1] != word2[index2])  # current letters not identical
        return min(
            1 + min_distance(index1 + 1, index2),
            1 + min_distance(index1, index2 + 1),
            diff + min_distance(index1 + 1, index2 + 1),
        )