#include <bits/stdc++.h>
using namespace std;
int main(void) {
  string s, t;
  cin >> s >> t;
  long long repnum = 0;
  long long nows = 0;
  long long nowt = 0;
  long long boolcount = 0;
  while (nowt < t.size()) {
    if (boolcount >= s.size()) {
      cout << -1 << endl;
      return 0;
    }
    if (s[nows] == t[nowt]) {
      nowt++;
      boolcount = 0;
    } else {
      boolcount++;
    }
    if (nowt >= t.size()) break;
    nows++;
    nows %= s.size();
    if (nows == 0) {
      repnum++;
    }
  }
  if ((long long)(repnum * s.size()) + nows + 1 > pow(10, 100) * s.size()) {
    cout << -1 << endl;
    return 0;
  }
  cout << (long long)(repnum * s.size()) + nows + 1 << endl;
  return 0;
}
