"""simple docstring"""






class 				snake_case       :




					"""simple docstring"""

					def __init__(				self   :	int    ,lowerCamelCase__   :	int    ,lowerCamelCase__   :	Union[str, Any]=None    ,lowerCamelCase__   :	List[str]=None			):
									UpperCAmelCase__             =							data
									UpperCAmelCase__             =							previous
									UpperCAmelCase__             =							next_node







					def __str__(				self   :	List[Any]			):
									return f'''{self.data}'''







					def 		__lowerCAmelCase						(				self   :	str			):
									return self.data







					def 		__lowerCAmelCase						(				self   :	Tuple			):
									return self.next







					def 		__lowerCAmelCase						(				self   :	List[Any]			):
									return self.previous






class 				snake_case       :




					"""simple docstring"""

					def __init__(				self   :	Any    ,lowerCamelCase__   :	List[Any]			):
									UpperCAmelCase__             =							head







					def __iter__(				self   :	Optional[int]			):
									return self







					def 		__lowerCAmelCase						(				self   :	List[Any]			):
									if not self.current:
													raise StopIteration
									else:
													UpperCAmelCase__             =							self.current.get_data()
													UpperCAmelCase__             =							self.current.get_next()
													return value






class 				snake_case       :




					"""simple docstring"""

					def __init__(				self   :	Dict			):
									UpperCAmelCase__             =							None  # First node in list
									UpperCAmelCase__             =							None  # Last node in list







					def __str__(				self   :	Tuple			):
									UpperCAmelCase__             =							self.head
									UpperCAmelCase__             =							[]
									while current is not None:
													nodes.append(current.get_data()			)
													UpperCAmelCase__             =							current.get_next()
									return " ".join(str(lowerCamelCase__			) for node in nodes			)







					def __contains__(				self   :	Optional[int]    ,lowerCamelCase__   :	int			):
									UpperCAmelCase__             =							self.head
									while current:
													if current.get_data() == value:
																	return True
													UpperCAmelCase__             =							current.get_next()
									return False







					def __iter__(				self   :	str			):
									return LinkedListIterator(self.head			)







					def 		__lowerCAmelCase						(				self   :	str			):
									if self.head:
													return self.head.get_data()
									return None







					def 		__lowerCAmelCase						(				self   :	Optional[Any]			):
									if self.tail:
													return self.tail.get_data()
									return None







					def 		__lowerCAmelCase						(				self   :	str    ,lowerCamelCase__   :	Node			):
									if self.head is None:
													UpperCAmelCase__             =							node
													UpperCAmelCase__             =							node
									else:
													self.insert_before_node(self.head    ,lowerCamelCase__			)







					def 		__lowerCAmelCase						(				self   :	Tuple    ,lowerCamelCase__   :	Node			):
									if self.head is None:
													self.set_head(lowerCamelCase__			)
									else:
													self.insert_after_node(self.tail    ,lowerCamelCase__			)







					def 		__lowerCAmelCase						(				self   :	List[Any]    ,lowerCamelCase__   :	int			):
									UpperCAmelCase__             =							Node(lowerCamelCase__			)
									if self.head is None:
													self.set_head(lowerCamelCase__			)
									else:
													self.set_tail(lowerCamelCase__			)







					def 		__lowerCAmelCase						(				self   :	List[str]    ,lowerCamelCase__   :	Node    ,lowerCamelCase__   :	Node			):
									UpperCAmelCase__             =							node
									UpperCAmelCase__             =							node.previous

									if node.get_previous() is None:
													UpperCAmelCase__             =							node_to_insert
									else:
													UpperCAmelCase__             =							node_to_insert

									UpperCAmelCase__             =							node_to_insert







					def 		__lowerCAmelCase						(				self   :	Tuple    ,lowerCamelCase__   :	Node    ,lowerCamelCase__   :	Node			):
									UpperCAmelCase__             =							node
									UpperCAmelCase__             =							node.next

									if node.get_next() is None:
													UpperCAmelCase__             =							node_to_insert
									else:
													UpperCAmelCase__             =							node_to_insert

									UpperCAmelCase__             =							node_to_insert







					def 		__lowerCAmelCase						(				self   :	Optional[Any]    ,lowerCamelCase__   :	int    ,lowerCamelCase__   :	int			):
									UpperCAmelCase__             =							1
									UpperCAmelCase__             =							Node(lowerCamelCase__			)
									UpperCAmelCase__             =							self.head
									while node:
													if current_position == position:
																	self.insert_before_node(lowerCamelCase__    ,lowerCamelCase__			)
																	return
													current_position += 1
													UpperCAmelCase__             =							node.next
									self.insert_after_node(self.tail    ,lowerCamelCase__			)







					def 		__lowerCAmelCase						(				self   :	str    ,lowerCamelCase__   :	int			):
									UpperCAmelCase__             =							self.head
									while node:
													if node.get_data() == item:
																	return node
													UpperCAmelCase__             =							node.get_next()
									raise Exception('Node not found'			)







					def 		__lowerCAmelCase						(				self   :	Dict    ,lowerCamelCase__   :	Any			):
									if (node := self.get_node(lowerCamelCase__			)) is not None:
													if node == self.head:
																	UpperCAmelCase__             =							self.head.get_next()

													if node == self.tail:
																	UpperCAmelCase__             =							self.tail.get_previous()

													self.remove_node_pointers(lowerCamelCase__			)







					@staticmethod
					def 		__lowerCAmelCase						(				lowerCamelCase__   :	Node			):
									if node.get_next():
													UpperCAmelCase__             =							node.previous

									if node.get_previous():
													UpperCAmelCase__             =							node.next

									UpperCAmelCase__             =							None
									UpperCAmelCase__             =							None







					def 		__lowerCAmelCase						(				self   :	Union[str, Any]			):
									return self.head is None






def   a_						(					):
				pass


if __name__ == "__main__":
						import doctest

						doctest.testmod()




"""simple docstring"""






import functools



def   a_						(					lowerCamelCase					,			lowerCamelCase       ):
				UpperCAmelCase__             =							len(lowerCamelCase       )
				UpperCAmelCase__             =							len(lowerCamelCase       )

				@functools.cache
				def min_distance(lowerCamelCase					,			lowerCamelCase       ) -> int:
								# if first word index is overflow - delete all from the second word
								if indexa >= len_worda:
												return len_worda - indexa
								# if second word index is overflow - delete all from the first word
								if indexa >= len_worda:
												return len_worda - indexa
								UpperCAmelCase__             =							int(worda[indexa] != worda[indexa]       )  # current letters not identical
								return min(
								    1 + min_distance(indexa + 1					,			lowerCamelCase       )					,			1 + min_distance(lowerCamelCase					,			indexa + 1       )					,			diff + min_distance(indexa + 1					,			indexa + 1       )					,			)

				return min_distance(0					,			0       )


if __name__ == "__main__":
						import doctest

						doctest.testmod()



