#include <bits/stdc++.h>
using namespace std;
char s1[10010], s2[1000010];
int d[1000010];
int a[26][1000010];
int p[26] = {0};
int main() {
  int ans = 1;
  gets(s1);
  gets(s2);
  int P = strlen(s1);
  for (int i = 0; i < P; i++) {
    a[s1[i] - 'a'][p[s1[i] - 'a']] = i;
    p[s1[i] - 'a']++;
  }
  int s = 0;
  int L = strlen(s2);
  for (int i = 0; i < L; i++) {
    if (p[s2[i] - 'a'] == 0) {
      printf("-1\n");
      return 0;
    }
    int tmp = a[s2[i] - 'a'][0];
    int l = p[s2[i] - 'a'];
    if (i > 0) {
      int lo = 0, hi = l - 1, m;
      while (lo <= hi) {
        m = lo + (hi - lo) / 2;
        if (a[s2[i] - 'a'][m] > d[i - 1]) {
          tmp = a[s2[i] - 'a'][m];
          hi = m - 1;
        } else
          lo = m + 1;
      }
    }
    d[s++] = tmp;
  }
  for (int i = 0; i < s - 1; i++) {
    if (d[i] >= d[i + 1]) ans++;
  }
  printf("%d\n", ans);
  return 0;
}
