#include <bits/stdc++.h>
int bio[256];
int next[10004][26];
char A[10004];
char B[1000004];
int solve(void) {
  memset(bio, 0, sizeof(bio));
  for (int i = 0; A[i]; ++i) bio[A[i]] = true;
  for (int i = 0; B[i]; ++i)
    if (!bio[B[i]]) return -1;
  int n = strlen(A);
  memset(next[n], -1, sizeof(next[0]));
  for (int i = 0; i < n; ++i)
    if (next[n][A[i] - 'a'] == -1) next[n][A[i] - 'a'] = i;
  for (int i = n - 1; i >= 0; --i) {
    for (int j = 0; j < 26; ++j) next[i][j] = next[i + 1][j];
    next[i][A[i] - 'a'] = i;
  }
  int result = 1;
  int poz = 0;
  for (int i = 0; B[i]; ++i) {
    if (A[poz] == B[i]) {
      ++poz;
    } else {
      if (next[poz][B[i] - 'a'] <= poz) ++result;
      poz = next[poz][B[i] - 'a'] + 1;
    }
    if (poz == n) {
      poz = 0;
      if (B[i + 1]) ++result;
    }
  }
  return result;
}
int main(void) {
  scanf("%s", A);
  scanf("%s", B);
  printf("%d\n", solve());
  return 0;
}
