#include <bits/stdc++.h>
using namespace std;
char s[20000];
char c[1100000];
int a[30][20000];
int main() {
  int i, j, n, m, k, l, o, p, ls, lc, ts, flag = 0, tf;
  scanf("%s", s);
  ls = strlen(s);
  memset(a, 0, sizeof(a));
  for (i = 0; i < ls; i++) {
    k = s[i] - 96;
    a[k][0]++;
    a[k][a[k][0]] = i;
  }
  for (i = 1; i <= 26; i++) {
    a[i][a[i][0] + 1] = -1;
    a[i][0] = 1;
  }
  scanf("%s", c);
  lc = strlen(c);
  m = 0;
  l = -1;
  tf = 0;
  for (i = 0; i < lc; i++) {
    k = c[i] - 96;
    if (a[k][a[k][0]] == -1 && a[k][0] == 1) {
      flag = 1;
      break;
    }
    while (a[k][a[k][0]] != -1 && a[k][a[k][0]] <= l) a[k][0]++;
    if (a[k][a[k][0]] == -1) {
      for (j = 1; j <= 26; j++) a[j][0] = 1;
      l = -1;
      m++;
      i--;
    } else {
      l = a[k][a[k][0]];
      a[k][0]++;
    }
  }
  if (flag)
    printf("-1\n");
  else
    printf("%d\n", m + 1);
  return 0;
}
