Codeforces Beta Round 75 (Div. 2 Only)
C
Newspaper Headline
Codeforces
未评级
原题
← BD →
翻译中…

A newspaper is published in Walrusland. Its heading is $*s*_{1}$, it consists of lowercase Latin letters. Fangy the little walrus wants to buy several such newspapers, cut out their headings, glue them one to another in order to get one big string. After that walrus erase several letters from this string in order to get a new word $*s*_{2}$. It is considered that when Fangy erases some letter, there's no whitespace formed instead of the letter. That is, the string remains unbroken and it still only consists of lowercase Latin letters.

翻译中…

For example, the heading is "abc". If we take two such headings and glue them one to the other one, we get "abcabc". If we erase the letters on positions $1$ and $5$, we get a word "bcac".

翻译中…

Which least number of newspaper headings $*s*_{1}$ will Fangy need to glue them, erase several letters and get word $*s*_{2}$?

翻译中…

Input

翻译中…

The input data contain two lines. The first line contain the heading $*s*_{1}$, the second line contains the word $*s*_{2}$. The lines only consist of lowercase Latin letters ($1 ≤ |*s*_{1}| ≤ 10^{4}, 1 ≤ |*s*_{2}| ≤ 10^{6}$).

翻译中…

Output

翻译中…

If it is impossible to get the word $*s*_{2}$ in the above-described manner, print "-1" (without the quotes). Otherwise, print the least number of newspaper headings $*s*_{1}$, which Fangy will need to receive the word $*s*_{2}$.

翻译中…

样例

Input #1
abc
xyz
Output #1
-1
InputCopy OutputCopy
Input #2
abcd
dabc
Output #2
2
InputCopy OutputCopy
题目信息
题号
92C
时间限制
2 s
内存限制
256 MB

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。