#include <bits/stdc++.h>
using namespace std;
vector<long long> graph[200004];
long long value[200004];
long long visited[200005];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s, t;
  cin >> s >> t;
  long long i, j;
  long long n, m;
  n = s.size();
  m = t.size();
  map<char, long long> m1, m2;
  for (i = 0; i < n; i++) {
    m1[s[i]] = 1;
  }
  for (i = 0; i < m; i++) {
    if (m1.find(t[i]) == m1.end()) {
      cout << -1 << endl;
      return 0;
    }
  }
  i = 0;
  j = 0;
  long long c = 0;
  long long pre = 0;
  while (j < m) {
    c++;
    if (s[i] == t[j]) {
      i++;
      j++;
      pre = c;
      i = i % n;
      continue;
    } else {
      i++;
      i = i % n;
    }
    if (c - pre > 2 * n) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << c << endl;
  return 0;
}
