#include <bits/stdc++.h>
using namespace std;
int nxt[32][10000];
int main() {
  char o[10001];
  char r[1000001];
  scanf("%s\n%s", o, r);
  int last[32];
  for (char c = 'a'; c <= 'z'; c++) {
    last[c - 'a'] = -1;
  }
  int len = strlen(o);
  for (int i = 0; i < len; i++) {
    if (last[o[i] - 'a'] == -1) {
      last[o[i] - 'a'] = i;
    }
  }
  for (int i = len - 1; i >= 0; i--) {
    for (int j = 'a'; j <= 'z'; j++) {
      nxt[j - 'a'][i] = last[j - 'a'];
    }
    last[o[i] - 'a'] = i;
  }
  int cnt = 0;
  int ps = len - 1;
  int ln = strlen(r);
  for (int j = 0; j < ln; j++) {
    if (nxt[r[j] - 'a'][ps] == -1) {
      printf("-1\n");
      return 0;
    }
    if (nxt[r[j] - 'a'][ps] <= ps) {
      cnt++;
    }
    ps = nxt[r[j] - 'a'][ps];
  }
  printf("%d\n", cnt);
  return 0;
}
