#abc257g. [abc257_g]Prefix Concatenation
[abc257_g]Prefix Concatenation
Problem Statement
You are given two strings and consisting of lowercase English letters.
Find the minimum positive integer such that you can choose (not necessarily distinct) prefixes of so that their concatenation coincides with .
In other words, find the minimum positive integer such that there exists a -tuple of integers between and such that
, where denotes the substring of from the -st through the -th characters and denotes the concatenation of strings.
If it is impossible to make it coincide with , print instead.
Constraints
- and are strings consisting of lowercase English letters.
Input
Input is given from Standard Input in the following format:
Output
Print the minimum positive integer such that you can choose prefixes of so that their concatenation coincides with . It is impossible to make it coincide with , print instead.
Sample Input 1
aba
ababaab
Sample Output 1
3
ababaab
can be written as ab
+ aba
+ ab
, of which ab
and aba
are prefixes of aba
.
Since it is unable to express ababaab
with two or less prefixes of aba
, print .
Sample Input 2
atcoder
ac
Sample Output 2
-1
Since it is impossible to express as a concatenation of prefixes of , print .