Codeforces Round 110 (Div. 1)
A
Message
Codeforces
1700
原题
←B →
翻译中…

Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string $*s*$.

翻译中…

String $*p*$ is called a substring of string $*s*$ if you can read it starting from some position in the string $*s*$. For example, string "aba" has six substrings: "a", "b", "a", "ab", "ba", "aba".

翻译中…

Dr. Moriarty plans to take string $*s*$ and cut out some substring from it, let's call it $*t*$. Then he needs to change the substring $*t*$ zero or more times. As a result, he should obtain a fixed string $*u*$ (which is the string that should be sent to Sherlock Holmes). One change is defined as making one of the following actions:

翻译中…
  • Insert one letter to any end of the string.
  • Delete one letter from any end of the string.
  • Change one letter into any other one.
翻译中…

Moriarty is very smart and after he chooses some substring $*t*$, he always makes the minimal number of changes to obtain $*u*$.

翻译中…

Help Moriarty choose the best substring $*t*$ from all substrings of the string $*s*$. The substring $*t*$ should minimize the number of changes Moriarty should make to obtain the string $*u*$ from it.

翻译中…

Input

翻译中…

The first line contains a non-empty string $*s*$, consisting of lowercase Latin letters. The second line contains a non-empty string $*u*$, consisting of lowercase Latin letters. The lengths of both strings are in the range from $1$ to $2000$, inclusive.

翻译中…

Output

翻译中…

Print the only integer — the minimum number of changes that Dr. Moriarty has to make with the string that you choose.

翻译中…

Note

翻译中…

In the first sample Moriarty can take any substring of length $3$, and it will be equal to the required message $*u*$, so Moriarty won't have to make any changes.

翻译中…

In the second sample you should take a substring consisting of characters from second to fourth ("bca") or from fifth to sixth ("bc"). Then you will only have to make one change: to change or to add the last character.

翻译中…

In the third sample the initial string $*s*$ doesn't contain any character that the message should contain, so, whatever string you choose, you will have to make at least $7$ changes to obtain the required message.

翻译中…

样例

Input #1
aaaaa
aaa
Output #1
0
InputCopy OutputCopy
Input #2
abcabc
bcd
Output #2
1
InputCopy OutputCopy
Input #3
abcdef
klmnopq
Output #3
7
InputCopy OutputCopy
题目信息
题号
156A
时间限制
2 s
内存限制
256 MB
标签
暴力

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。