
'''simple docstring'''





def 							SCREAMING_SNAKE_CASE_      (			UpperCamelCase__		):
      UpperCamelCase__    :   Dict					=				[0 for i in range(len(UpperCamelCase__		)		)]

      # initialize interval's left pointer and right pointer
      UpperCamelCase__    :   Any					=				0, 0

      for i in range(1 ,		len(UpperCamelCase__		)		):
            # case when current index is inside the interval
            if i <= right_pointer:
                  UpperCamelCase__    :   Optional[int]					=				min(right_pointer - i + 1 ,		z_result[i - left_pointer]		)
                  UpperCamelCase__    :   List[Any]					=				min_edge

            while go_next(UpperCamelCase__ ,		UpperCamelCase__ ,		UpperCamelCase__		):
                  z_result[i] += 1

            # if new index's result gives us more right interval,
            # we've to update left_pointer and right_pointer
            if i + z_result[i] - 1 > right_pointer:
                  UpperCamelCase__    :   Tuple					=				i, i + z_result[i] - 1

      return z_result


def 							SCREAMING_SNAKE_CASE_      (			UpperCamelCase__ ,		UpperCamelCase__ ,		UpperCamelCase__		):
      return i + z_result[i] < len(UpperCamelCase__		) and s[z_result[i]] == s[i + z_result[i]]


def 							SCREAMING_SNAKE_CASE_      (			UpperCamelCase__ ,		UpperCamelCase__		):
      UpperCamelCase__    :   Union[str, Any]					=				0
      # concatenate 'pattern' and 'input_str' and call z_function
      # with concatenated string
      UpperCamelCase__    :   Optional[Any]					=				z_function(pattern + input_str		)

      for val in z_result:
            # if value is greater then length of the pattern string
            # that means this index is starting position of substring
            # which is equal to pattern string
            if val >= len(UpperCamelCase__		):
                  answer += 1

      return answer


if __name__ == "__main__":
    import doctest

    doctest.testmod()




class 				_lowerCamelCase :





     """simple docstring"""







     def __init__(							self  )  ->   Tuple:




           """simple docstring"""







           UpperCamelCase__    :   Union[str, Any]					=				''''''
           UpperCamelCase__    :   int					=				''''''
           UpperCamelCase__    :   Optional[int]					=				[]






     def    __SCREAMING_SNAKE_CASE			(							self						,						__SCREAMING_SNAKE_CASE						,						__SCREAMING_SNAKE_CASE  )  ->   int:




           """simple docstring"""







           if m == -1:
                 return n + 1
           elif n == -1:
                 return m + 1
           elif self.dp[m][n] > -1:
                 return self.dp[m][n]
           else:
                 if self.worda[m] == self.worda[n]:
                       UpperCamelCase__    :   Union[str, Any]					=				self.__min_dist_top_down_dp(m - 1						,						n - 1  )
                 else:
                       UpperCamelCase__    :   int					=				self.__min_dist_top_down_dp(__SCREAMING_SNAKE_CASE						,						n - 1  )
                       UpperCamelCase__    :   Tuple					=				self.__min_dist_top_down_dp(m - 1						,						__SCREAMING_SNAKE_CASE  )
                       UpperCamelCase__    :   Optional[Any]					=				self.__min_dist_top_down_dp(m - 1						,						n - 1  )
                       UpperCamelCase__    :   Optional[int]					=				1 + min(__SCREAMING_SNAKE_CASE						,						__SCREAMING_SNAKE_CASE						,						__SCREAMING_SNAKE_CASE  )

                 return self.dp[m][n]






     def    __SCREAMING_SNAKE_CASE			(							self						,						__SCREAMING_SNAKE_CASE						,						__SCREAMING_SNAKE_CASE  )  ->   int:




           """simple docstring"""







           UpperCamelCase__    :   Union[str, Any]					=				worda
           UpperCamelCase__    :   Any					=				worda
           UpperCamelCase__    :   List[str]					=				[[-1 for _ in range(len(__SCREAMING_SNAKE_CASE  )  )] for _ in range(len(__SCREAMING_SNAKE_CASE  )  )]

           return self.__min_dist_top_down_dp(len(__SCREAMING_SNAKE_CASE  ) - 1						,						len(__SCREAMING_SNAKE_CASE  ) - 1  )






     def    __SCREAMING_SNAKE_CASE			(							self						,						__SCREAMING_SNAKE_CASE						,						__SCREAMING_SNAKE_CASE  )  ->   int:




           """simple docstring"""







           UpperCamelCase__    :   int					=				worda
           UpperCamelCase__    :   List[str]					=				worda
           UpperCamelCase__    :   int					=				len(__SCREAMING_SNAKE_CASE  )
           UpperCamelCase__    :   Optional[Any]					=				len(__SCREAMING_SNAKE_CASE  )
           UpperCamelCase__    :   int					=				[[0 for _ in range(n + 1  )] for _ in range(m + 1  )]

           for i in range(m + 1  ):
                 for j in range(n + 1  ):
                       if i == 0:  # first string is empty
                             UpperCamelCase__    :   List[Any]					=				j
                       elif j == 0:  # second string is empty
                             UpperCamelCase__    :   Union[str, Any]					=				i
                       elif worda[i - 1] == worda[j - 1]:  # last characters are equal
                             UpperCamelCase__    :   List[Any]					=				self.dp[i - 1][j - 1]
                       else:
                             UpperCamelCase__    :   Union[str, Any]					=				self.dp[i][j - 1]
                             UpperCamelCase__    :   str					=				self.dp[i - 1][j]
                             UpperCamelCase__    :   Union[str, Any]					=				self.dp[i - 1][j - 1]
                             UpperCamelCase__    :   List[Any]					=				1 + min(__SCREAMING_SNAKE_CASE						,						__SCREAMING_SNAKE_CASE						,						__SCREAMING_SNAKE_CASE  )
           return self.dp[m][n]


if __name__ == "__main__":
    lowerCamelCase      =EditDistance()

    print("****************** Testing Edit Distance DP Algorithm ******************")
    print()

    lowerCamelCase      =input("Enter the first string: ").strip()
    lowerCamelCase      =input("Enter the second string: ").strip()

    print()
    print(F'''The minimum edit distance is: {solver.min_dist_top_down(Sa, Sa)}''')
    print(F'''The minimum edit distance is: {solver.min_dist_bottom_up(Sa, Sa)}''')
    print()
    print("*************** End of Testing Edit Distance DP Algorithm ***************")


