DMOPC '20 Contest 5 P1 - Home Row

View as PDF

Submit solution


Points: 3
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type

As a 30 WPM typer, you are sitting in a computer lab playing a modified version of TypeRacer in hopes of increasing your typing speed. In this game, your goal is to transform a given string of lowercase characters S into a new string of lowercase characters T. S is the string you start with on your screen. In one keystroke, you can delete a character from the back of the current string on your screen, or you can add a new lowercase character to the back of the current string. Since you strive to be as fast as possible, please compute the minimum number of keystrokes needed to transform S into T.

Constraints

1 \le |S|, |T| \le 10^6, where |A| denotes the number of characters in A.

S and T only contain lowercase characters.

Input Specification

The first line contains the string S.

The second line contains the string T.

Output Specification

Output one integer, the minimum number of keystrokes needed to transform S into T.

Sample Input 1

adachi
shimamura

Sample Output 1

15

Sample Input 2

shinomiya
shirogane

Sample Output 2

12

Comments

There are no comments at the moment.