#abc138e. [abc138_e]Strings of Impurity

[abc138_e]Strings of Impurity

Problem Statement

Given are two strings ss and tt consisting of lowercase English letters. Determine if there exists an integer ii satisfying the following condition, and find the minimum such ii if it exists.

  • Let ss' be the concatenation of 1010010^{100} copies of ss. tt is a subsequence of the string s1s2ldotssi{s'}_1{s'}_2\\ldots{s'}_i (the first ii characters in ss').

Notes

  • A subsequence of a string aa is a string obtained by deleting zero or more characters from aa and concatenating the remaining characters without changing the relative order. For example, the subsequences of contest include net, c, and contest.

Constraints

  • 1leqsleq1051 \\leq |s| \\leq 10^5
  • 1leqtleq1051 \\leq |t| \\leq 10^5
  • ss and tt consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:

ss tt

Output

If there exists an integer ii satisfying the following condition, print the minimum such ii; otherwise, print -1.


Sample Input 1

contest
son

Sample Output 1

10

t=t = son is a subsequence of the string contestcon (the first 1010 characters in s=s' = contestcontestcontest...), so i=10i = 10 satisfies the condition.

On the other hand, tt is not a subsequence of the string contestco (the first 99 characters in ss'), so i=9i = 9 does not satisfy the condition.

Similarly, any integer less than 99 does not satisfy the condition, either. Thus, the minimum integer ii satisfying the condition is 1010.


Sample Input 2

contest
programming

Sample Output 2

-1

t=t = programming is not a substring of s=s' = contestcontestcontest.... Thus, there is no integer ii satisfying the condition.


Sample Input 3

contest
sentence

Sample Output 3

33

Note that the answer may not fit into a 3232-bit integer type, though we cannot put such a case here.