#include <bits/stdc++.h>
using namespace std;
char buf[10001], buf2[1000001];
int tab[100001][26];
int main() {
  scanf("%s %s", buf, buf2);
  int len = strlen(buf), len2 = strlen(buf2);
  for (int i = 0; i < 26; i++) tab[len - 1][i] = -1;
  for (int ti = 2 * len - 2; ti >= 0; ti--) {
    int i = ti % len;
    for (int j = 0; j < 26; j++)
      tab[i][j] = buf[i] == 'a' + j ? i : tab[(i + 1) % len][j];
  }
  for (int i = 0; i < len; i++) {
    for (int j = 0; j < 26; j++)
      if (tab[i][j] != -1)
        ;
    ;
  }
  int ind = len - 1, loop = 0;
  for (int i = 0; i < len2; i++) {
    int c = buf2[i] - 'a';
    int newind = tab[(ind + 1) % len][c];
    ;
    if (newind <= ind) loop++;
    if (newind == -1) {
      printf("-1\n");
      return 0;
    }
    ind = newind;
  }
  printf("%d\n", loop);
  return 0;
}
