Problem N: 编辑距离

Problem N: 编辑距离

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 15  Solved: 7
[Status] [Submit] [Creator:]

Description

两个字符串的编辑距离(edit distance)是指给定字符串s1和s2,以及在s1上的如下操作:

  • 插入(Insert)一个字符
  • 移除(Remove)一个字符
  • 替换(Replace)一个字符

试问最小需要多少次这样的操作才能使得s1转换为s2?



示例 1:  

输入: s1= "horse", s2= "ros" 

输出: 3 

解释:  

horse -> rorse (将 'h' 替换为 'r')

rorse -> rose (删除 'r') 

rose -> ros (删除 'e')



Input

两行,一行一个字符串,每个字符串长度不超过300

Output

一个整数,代表编辑距离。

Sample Input Copy

horse
ros

Sample Output Copy

3