A newspaper is published in Walrusland. Its heading is s1, it consists of lowercase Latin letters. Fangy the little walrus wants to buy several such newspapers, cut out their headings, glue them one to another in order to get one big string. After that walrus erase several letters from this string in order to get a new word s2. It is considered that when Fangy erases some letter, there's no whitespace formed instead of the letter. That is, the string remains unbroken and it still only consists of lowercase Latin letters.

For example, the heading is "abc". If we take two such headings and glue them one to the other one, we get "abcabc". If we erase the letters on positions 1 and 5, we get a word "bcac".

Which least number of newspaper headings s1 will Fangy need to glue them, erase several letters and get word s2?

Input

The input data contain two lines. The first line contain the heading s1, the second line contains the word s2. The lines only consist of lowercase Latin letters (1 ≤ |s1| ≤ 104, 1 ≤ |s2| ≤ 106).

Output

If it is impossible to get the word s2 in the above-described manner, print "-1" (without the quotes). Otherwise, print the least number of newspaper headings s1, which Fangy will need to receive the word s2.

Examples

Input

abc
xyz


Output

-1


Input

abcd
dabc


Output

2
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
template <typename X>
inline X abs(const X& a) {
  return a < 0 ? -a : a;
}
template <typename X>
inline X sqr(const X& a) {
  return a * a;
}
const int size = 1e5 + 2;
const double eps = 0.0001;
const long double PI = 3.1415926535897932384626433832795;
const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const long long MAX5 = 100001;
const long long MAX6 = 1000001;
const long long MAX17 = 99999999999999999;
const double DMAX = 2e18 + 5;
void solution();
void include_file();
int main() {
  ios_base::sync_with_stdio(false);
  solution();
  return 0;
}
void include_file() {
  ios_base::sync_with_stdio(true);
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
}
inline bool isPrime(long long n) {
  for (int i = 2; i * i <= n; ++i)
    if (n % i == 0) return false;
  return true;
}
string ekv(string a) {
  if (a.size() & 1) return a;
  string x = ekv(a.substr(0, a.size() / 2));
  string y = ekv(a.substr(a.size() / 2));
  return min(x + y, y + x);
}
long long cubic_root(long long x) {
  long long l = 0, r = MAX6;
  while (l != r) {
    long long m = (l + r + 1) / 2;
    if (m * m * m > x)
      r = m - 1;
    else
      l = m;
  }
  return l;
}
float FastInvSqrt(float x) {
  float xhalf = 0.5f * x;
  int i = *(int*)&x;
  i = 0x5f3759df - (i >> 1);
  x = *(float*)&i;
  x = x * (1.5f - (xhalf * x * x));
  return x;
}
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
void yes() { cout << "YES"; }
void no() { cout << "NO"; }
void yes(bool res) {
  if (res)
    cout << "YES";
  else
    cout << "NO";
}
void dabl(double x) { printf("%.10lf", x); }
namespace bits {
template <typename X>
inline X MAX(const X& a, const X& b) {
  return b & ((a - b) >> 31) | a & (~(a - b) >> 31);
}
template <typename X>
inline X MIN(const X& a, const X& b) {
  return a & ((a - b) >> 31) | b & (~(a - b) >> 31);
}
bool check2(const long long n) { return n > 0 && (n & (n - 1)); }
long long ostatok2(const long long n, const long long m) { return m & (n - 1); }
template <typename X>
void SWAP(X& a, X& b) {
  a ^= b;
  b ^= a;
  a ^= b;
}
size_t count_1_in_LL(unsigned long long n) {
  std::size_t i(0);
  for (; n; ++i) n &= n - 1;
  return i;
}
}  // namespace bits
vector<vector<int> > g;
inline void solution() {
  string a, b;
  cin >> a >> b;
  int res = 1;
  set<char> q;
  for (long long i = 0; i < a.size(); ++i) q.insert(a[i]);
  for (long long i = 0; i < b.size(); ++i)
    if (!q.count(b[i])) {
      cout << -1;
      return;
    }
  vector<int> posa[26];
  for (long long i = 0; i < a.size(); ++i) posa[a[i] - 'a'].push_back(i);
  bool bb = 0;
  int cur = -1;
  for (long long i = 0; i < b.size(); ++i) {
    auto it =
        upper_bound((posa[b[i] - 'a']).begin(), (posa[b[i] - 'a']).end(), cur);
    if (it == posa[b[i] - 'a'].end()) {
      cur = posa[b[i] - 'a'][0];
      res++;
    } else
      cur = *it;
  };
  cout << res;
  ;
}
