CF91A.Newspaper Headline

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

A newspaper is published in Walrusland. Its heading is s1s_{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 s2s_{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 11 and 55 , we get a word "bcac".

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

输入格式

The input data contain two lines. The first line contain the heading s1s_{1} , the second line contains the word s2s_{2} . The lines only consist of lowercase Latin letters ( 1<=s1<=104,1<=s2<=1061<=|s_{1}|<=10^{4},1<=|s_{2}|<=10^{6} ).

输出格式

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

输入输出样例

  • 输入#1

    abc
    xyz
    

    输出#1

    -1
    
  • 输入#2

    abcd
    dabc
    

    输出#2

    2
    
首页