100 atcoder#AGC007F. [AGC007F] Shik and Copying String
[AGC007F] Shik and Copying String
Score : points
Problem Statement
Shik's job is very boring. At day , his boss gives him a string of length which consists of only lowercase English letters. In the -th day after day , Shik's job is to copy the string to a string . We denote the -th letter of as .
Shik is inexperienced in this job. In each day, when he is copying letters one by one from the first letter to the last letter, he would make mistakes. That is, he sometimes accidentally writes down the same letter that he wrote previously instead of the correct one. More specifically, is equal to either or . (Note that always equals to .)
You are given the string and another string .
Please determine the smallest integer such that could be equal to . If no such exists, please print -1
.
Constraints
- The lengths of and are both .
- Both and consist of lowercase English letters.
Input
The input is given from Standard Input in the following format:
Output
Print the smallest integer such that could be equal to . If no such exists, print -1
instead.
5
abcde
aaacc
2
= abcde
, = aaccc
and = aaacc
is a possible sequence such that .
5
abcde
abcde
0
4
acaa
aaca
2
5
abcde
bbbbb
-1