Skip to main content
LIVE CONTEST: ALGOR Contest: Round #4 (Special Challenge) is live now!

~/algor $ cat problems/dp-tahrirlash-masofasi

Edit distance

Medium 1000 ms 128 MB 60%
Share

Two strings $s$ and $t$ are given. In one operation you may insert one letter anywhere into $s$, delete one letter from it, or replace one of its letters with another. What is the smallest number of operations needed to turn $s$ into $t$?

Letters of two strings one above the other; matching letters are joined, inserted, deleted and replaced letters are highlighted

Input

The first line contains the string $s$, the second line contains the string $t$.

Output

One integer — the smallest number of operations.

Note

$1 \le |s|, |t| \le 1000$
the strings consist only of lowercase Latin letters (a–z)

Examples

Input #1
kitob
kitoblar
Output #1
3
Input #2
olma
olma
Output #2
0

Sign in to submit a solution

Signing up is free and takes a minute.