1 #define bug(x) cout<<#x<<" is "<<x<<endl
2 #define IO std::ios::sync_with_stdio(0)
3 #include <bits/stdc++.h>
4 using namespace std;
5 typedef long long ll;
6 #define mk make_pair
7 #define pb push_back
8 const int inf=2147483647;
9 const int N=1e5+10;
10 char s[N];
11 char t[N];
12
13
14 int a[N][26];
15 int vis[26];
16 int ok[N][26];
17
18 int main(){
19 while(~scanf("%s",s+1)){
20 int n=strlen(s+1);
21 scanf("%s",t+1);
22 int m=strlen(t+1);
23 for(int i=0;i<26;i++)a[n+1][i]=0 ,vis[i]=0;
24 for(int i=n;i>=0;i--){
25 vis[s[i]-'a']=1;
26 for(int j=0;j<26;j++){
27 if(s[i]==j+'a')a[i][j]=i;
28 else a[i][j]=a[i+1][j];
29 }
30 }
31 int ans=1,f=0,f1=0,j=1;
32 for(int i=1;i<=m;){
33 int x=t[i]-'a';
34 if(!vis[x]){
35 f1=1;
36 break;
37 }
38 j=a[j][x];
39 if(j)j++,i++;
40 else{
41 ans++;
42 j=1;
43 }
44 }
45 if(f1){
46 printf("-1
");
47 continue;
48 }
49 printf("%d
",ans);
50
51 }
52 }
53 /*
54 ab
55 abab
56
57 abb
58 bbaa
59
60 abc
61 bca
62
63 abb
64 abbabbabb
65 */