CF156A.Message

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Dr. Moriarty is about to send a message to Sherlock Holmes. He has a string ss .

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

Dr. Moriarty plans to take string ss and cut out some substring from it, let's call it tt . Then he needs to change the substring tt zero or more times. As a result, he should obtain a fixed string uu (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 tt , he always makes the minimal number of changes to obtain uu .

Help Moriarty choose the best substring tt from all substrings of the string ss . The substring tt should minimize the number of changes Moriarty should make to obtain the string uu from it.

输入格式

The first line contains a non-empty string ss , consisting of lowercase Latin letters. The second line contains a non-empty string uu , consisting of lowercase Latin letters. The lengths of both strings are in the range from 11 to 20002000 , inclusive.

输出格式

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

输入输出样例

  • 输入#1

    aaaaa
    aaa
    

    输出#1

    0
    
  • 输入#2

    abcabc
    bcd
    

    输出#2

    1
    
  • 输入#3

    abcdef
    klmnopq
    

    输出#3

    7
    

说明/提示

In the first sample Moriarty can take any substring of length 33 , and it will be equal to the required message uu , 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 ss doesn't contain any character that the message should contain, so, whatever string you choose, you will have to make at least 77 changes to obtain the required message.

首页