#ABC257G. [ABC257G] Prefix Concatenation

[ABC257G] Prefix Concatenation

Score : 600600 points

Problem Statement

You are given two strings SS and TT consisting of lowercase English letters.

Find the minimum positive integer kk such that you can choose (not necessarily distinct) kk prefixes of SS so that their concatenation coincides with TT.

In other words, find the minimum positive integer kk such that there exists a kk-tuple (a1,a2,,ak)(a_1,a_2,\ldots, a_k) of integers between 11 and S|S| such that T=Sa1+Sa2++SakT=S_{a_1}+S_{a_2}+\cdots +S_{a_k}, where SiS_i denotes the substring of SS from the 11-st through the ii-th characters and ++ denotes the concatenation of strings.

If it is impossible to make it coincide with TT, print 1-1 instead.

Constraints

  • 1S5×1051 \leq |S| \leq 5\times 10^5
  • 1T5×1051 \leq |T| \leq 5\times 10^5
  • SS and TT are strings consisting of lowercase English letters.

Input

Input is given from Standard Input in the following format:

SS

TT

Output

Print the minimum positive integer kk such that you can choose kk prefixes of SS so that their concatenation coincides with TT. It is impossible to make it coincide with TT, print 1-1 instead.

aba
ababaab
3

T=T= ababaab can be written as ab + aba + ab, of which ab and aba are prefixes of S=S= aba. Since it is unable to express ababaab with two or less prefixes of aba, print 33.

atcoder
ac
-1

Since it is impossible to express TT as a concatenation of prefixes of SS, print 1-1.