#P2138. 小Z的关系距离

小Z的关系距离

Description

Xiao Z has studied dialectical materialism and learned that connections are universal. Looking at the strings on his scratch paper, he wants to explore the relationships between them.

Xiao Z believes that for two strings a,ba,b, if each can delete no more than half of its own length of characters to become equal, then a,ba,b are said to have a relationship with distance 11. If there exists another string cc that has a distance of 11 with aa and a distance of nn with bb, then a,ba,b are said to have a relationship with distance n+1n + 1.

Now Xiao Z randomly selects two lowercase letter strings a,ba,b and wants to know the minimal relationship distance between them. Please help him.

Input Format

The first line contains a string aa.

The second line contains a string bb.

Output Format

The first line contains an integer indicating the minimal relationship distance between a,ba,b.

abcdef
axcyd
1
a
b
2
abb
baa
2

Hint

For 30%30\% of the testdata, a,ba,b are composed of the same letter.

For 100%100\% of the testdata, 1a,b1001 \leq |a|,|b| \leq 100.

Translated by ChatGPT 5