#include <bits/stdc++.h>
char s1[10005], s2[1000005];
int lens1, lens2, Firstch[26], Flag[10005][26], i, j, nowpos, findpos, ans;
int main() {
  scanf("%s%s", s1, s2);
  lens1 = strlen(s1);
  lens2 = strlen(s2);
  memset(Firstch, 255, sizeof(Firstch));
  memset(Flag, 255, sizeof(Flag));
  Firstch[s1[lens1 - 1] - 'a'] = lens1 - 1;
  for (i = lens1 - 2; i >= 0; i--) {
    for (j = 0; j <= 25; j++) Flag[i][j] = Flag[i + 1][j];
    if (i != lens1 - 1) Flag[i][s1[i + 1] - 'a'] = i + 1;
    Firstch[s1[i] - 'a'] = i;
  }
  nowpos = Firstch[s2[0] - 'a'];
  ans = 1;
  if (nowpos == -1) {
    ans = -1;
  } else {
    for (i = 1; i < lens2; i++) {
      if (Firstch[s2[i] - 'a'] == -1) {
        ans = -1;
        break;
      }
      findpos = Flag[nowpos][s2[i] - 'a'];
      if (findpos == -1) {
        ans++;
        nowpos = Firstch[s2[i] - 'a'];
      } else {
        nowpos = findpos;
      }
    }
  }
  printf("%d\n", ans);
}
