#include <bits/stdc++.h>
using namespace std;
long long max(long long a, long long b) {
  if (a > b) return a;
  return b;
}
long long min(long long a, long long b) {
  if (a < b) return a;
  return b;
}
int a[20000][100], N;
map<char, int> M;
int main() {
  string s, ss;
  cin >> s >> ss;
  for (int i = 0; i < max(s.length(), ss.length()); i++)
    if (ss[i % ss.length()] == s[i % s.length()]) N++;
  if (N == max(s.length(), ss.length())) {
    cout << max(s.length(), ss.length()) / min(s.length(), ss.length()) << endl;
    return 0;
  }
  for (int i = 0; i < s.length(); i++) {
    M[s[i]] = 1;
    for (int j = 0; j < 'z' - 'a' + 1; j++) a[i][j] = -1;
  }
  for (int i = 0; i < ss.length(); i++)
    if (M.find(ss[i]) == M.end()) {
      cout << -1 << endl;
      return 0;
    }
  for (int i = s.length() - 1; i >= 0; i--)
    a[s.length() - 1][s[i] - 'a'] = i + 1;
  for (int i = s.length() - 2; i >= 0; i--) {
    for (int j = 0; j < 'z' - 'a' + 1; j++)
      if (a[i + 1][j] != -1) a[i][j] = a[i + 1][j] + 1;
    a[i][s[i + 1] - 'a'] = 1;
  }
  long long kol = 0, k = 0;
  if (s[0] == ss[0]) kol = 0, k = 1;
  for (int i = k; i < ss.length(); i++) {
    kol += a[k % s.length()][ss[i] - 'a'];
    k += a[k % s.length()][ss[i] - 'a'];
  }
  cout << kol / s.length() + 1 << endl;
  cin >> kol;
}
