"""simple docstring"""






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

				# dp is a 2d matrix where dp[i][j] denotes whether prefix string of
				# length i of input_string matches with prefix string of length j of
				# given pattern.
				# "dp" stands for dynamic programming.
				UpperCAmelCase__             =							[[0 for i in range(lowerCamelCase       )] for j in range(lowerCamelCase       )]

				# since string of zero length match pattern of zero length
				UpperCAmelCase__             =							1

				# since pattern of zero length will never match with string of non-zero length
				for i in range(1					,			lowerCamelCase       ):
								UpperCAmelCase__             =							0

				# since string of zero length will match with pattern where there
				# is at least one * alternatively
				for j in range(1					,			lowerCamelCase       ):
								UpperCAmelCase__             =							dp[0][j - 2] if pattern[j - 1] == '*' else 0

				# now using bottom-up approach to find for all remaining lengths
				for i in range(1					,			lowerCamelCase       ):
								for j in range(1					,			lowerCamelCase       ):
												if input_string[i - 1] == pattern[j - 1] or pattern[j - 1] == ".":
																UpperCAmelCase__             =							dp[i - 1][j - 1]

												elif pattern[j - 1] == "*":
																if dp[i][j - 2] == 1:
																				UpperCAmelCase__             =							1
																elif pattern[j - 2] in (input_string[i - 1], "."):
																				UpperCAmelCase__             =							dp[i - 1][j]
																else:
																				UpperCAmelCase__             =							0
												else:
																UpperCAmelCase__             =							0

				return bool(dp[-1][-1]       )


if __name__ == "__main__":
						import doctest

						doctest.testmod()
						# inputing the strings
						# input_string = input("input a string :")
						# pattern = input("input a pattern :")

						lowerCAmelCase__  :  List[Any]						     =	'aab'
						lowerCAmelCase__  :  List[Any]						     =	'c*a*b'

						# using function to check whether given string matches the given pattern
						if match_pattern(input_string, pattern):
												print(F"""{input_string} matches the given pattern {pattern}""")
						else:
												print(F"""{input_string} does not match with the given pattern {pattern}""")




"""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()



