p02318 Edit Distance (Levenshtein Distance)_16181
Find the edit distance between given two words s1 and s2.

The disntace is the minimum number of single-character edits required to change one word into the other. The edits including the following operations:

* insertion: Insert a character at a particular position.
* deletion: Delete a character at a particular position.
* substitution: Change the character at a particular position to a different character

Constraints

* 1 ≤ length of s1 ≤ 1000
* 1 ≤ length of s2 ≤ 1000

Input


s1
s2


Two words s1 and s2 are given in the first line and the second line respectively. The words will consist of lower case characters.

Output

Print the edit distance in a line.

Examples

Input

acac
acm


Output

2


Input

icpc
icpc


Output

0
#include<iostream>
#include<algorithm>
#include<string>
 
using namespace std;
 
int dp[1001][1001];
 
int main(){
 
  string s1,s2;
  cin>>s1>>s2;
  for(int i=0;i<=s1.length();i++){
    dp[i][0] = i;
  }
  for(int j=0;j<=s2.length();j++){
    dp[0][j] = j;
  }
 
  for(int i=1;i<=s1.length();i++){
    for(int j=1;j<=s2.length();j++){
      int k=0;
      if(s1[i-1]==s2[j-1]){
	k=0;
      }else{
	k=1;
      }
      dp[i][j]=min(dp[i-1][j]+1,min(dp[i][j-1]+1,dp[i-1][j-1]+k));
    }
  }
  cout<<dp[s1.length()][s2.length()]<<endl;
  return 0;
}

