Time limit
2s
Memory limit
128 MB
The string distance from string O to string N is the minimum number of string insertion operations needed to make O equal to N. In one operation, you may insert any string at any position in O, including the beginning, the end, or between two existing characters.
Given two strings O and N, compute the string distance from O to N.
The first line contains string O, and the second line contains string N. Each string has length at most 1,000. Every character has an ASCII code from 32 through 126, inclusive. The whole line is part of the string, so spaces are significant.
Print the string distance from O to N on the first line. If it is impossible to make O equal to N, print -1.