91A.md (1578B)
1 Source: https://codeforces.com/problemset/problem/91/A 2 3 A. Newspaper Headline 4 5 time limit per test 6 7 2 seconds 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 stdin 16 17 output 18 19 stdout 20 21 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. 22 23 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". 24 25 Which least number of newspaper headings *s*1 will Fangy need to glue them, erase several letters and get word *s*2? 26 27 Input 28 29 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| ≤ 104, 1 ≤ |*s*2| ≤ 106). 30 31 Output 32 33 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. 34 35 Examples 36 37 Input 38 39 ``` 40 abc 41 xyz 42 ``` 43 44 Output 45 46 ``` 47 -1 48 ``` 49 50 Input 51 52 ``` 53 abcd 54 dabc 55 ``` 56 57 Output 58 59 ``` 60 2 61 ```