#include <bits/stdc++.h>
using namespace std;
char s1[10005], s2[1000005];
vector<int> f[30];
int main() {
  scanf("%s%s", s1, s2);
  for (int i = 0; s1[i]; i++) f[s1[i] - 'a'].push_back(i);
  int p2 = 0, cnt = 1;
  while (1) {
    int now = 0;
    while (1) {
      vector<int>::iterator vit =
          lower_bound(f[s2[p2] - 'a'].begin(), f[s2[p2] - 'a'].end(), now);
      if (vit == f[s2[p2] - 'a'].end())
        break;
      else {
        p2++;
        now = *vit + 1;
        if (!s2[p2]) break;
      }
    }
    if (!s2[p2]) break;
    if (!s2[cnt - 1]) break;
    cnt++;
  }
  if (s2[cnt - 1])
    printf("%d\n", cnt);
  else
    puts("-1");
}
