Shuffle

아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

Given a string of even length s=s_1s_ns = s\_1 \ldots s\_n, we define shuffle\mathrm{shuffle} operation which transforms a string into a new string according to the following rule:

shuffle(s)=s_1s_3s_n1s_2s_4s_n\mathrm{shuffle}(s) = s\_1 s\_3 \ldots s\_{n-1} s\_2 s\_4 \ldots s\_n

For example, shuffle(abcdef)=acebdf\mathrm{shuffle}(\texttt{abcdef}) = \texttt{acebdf}.

You are given two strings of equal even length, ss and tt. How many times do you have to apply shuffle operation to ss in order to get tt as a result?

In the other words, find minimum kk such that shuffle(shuffle(shuffle_k times(s)))=t\underbrace{\mathrm{shuffle}(\mathrm{shuffle}(\dots \mathrm{shuffle}}\_{k\ \mathrm{times}} (s)\dots)) = t or report that it is not possible to reach tt in any number of operations.

입력

The first line of input contains a string ss, the second contains a string tt (s=t|s| = |t|, 2s1062 \leq |s| \leq 10^6, s|s| is even). Both strings consist of lowercase English characters.

출력

Print minimum non-negative kk such that it is possible to obtain tt from ss by applying shuffle operation kk times (or maybe not applying at all if k=0k = 0), or print -1 if it is impossible.