All submissions for this problem are available.
Alice loves strings a lot. She found that a Sage came to their city of Mumbai. People started saying that sage is fulfilling their wish, if they solve the problem that Sage gives. Alice went to see the sage to find out if he is real or not. Sage asked her a question.How many minimum number of strings P, does she need to make a string (S). He gave her infinite number of strings of P. He told her she can concatenate any number of strings of P. Sage to make her life simple, told her that she can remove any unnecessary characters from the concatenated string. Alice needs your help in finding out the answer. Can you help Alice in finding the truthfulness of the Sage. If you cannot make string S, then Sage asked her to print “-1”.
First Line of the input contains string S.
Second line contains string P.
All the characters in the strings are Uppercased
Output should contain a single integer, as mentioned in the problem.
- 1 ≤ len(S) ≤ 100000
- 1 ≤ len(P) ≤ 100000
Input: ABB BACBAC Output: 2
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, PYP3, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.