#include <bits/stdc++.h>   using namespace std;   int nx[10000][26], al[26], l1, l2;   string s1, s2;   int main() {     cin >> s1 >> s2;     l1 = s1.size();     l2 = s2.size();     for (int i = 0; i < l1; i++) fill(nx[i], nx[i] + 26, -1);     fill(al, al + 26, -1);     for (int i = l1 - 1; i >= 0; i--) al[s1[i] -  a ] = i;     for (int i = l1 - 1; i >= 0; i--) {       for (int j = 0; j < 26; j++) nx[i][j] = al[j];       al[s1[i] -  a ] = i;     }     int cur = l1 - 1, ans = 0;     for (int i = 0; i < l2; i++) {       if (nx[cur][s2[i] -  a ] == -1) {         cout << -1 << endl;         return 0;       }       if (nx[cur][s2[i] -  a ] <= cur) ans++;       cur = nx[cur][s2[i] -  a ];     }     cout << ans << endl;   }   