#include <bits/stdc++.h>
using namespace std;
using lint = long long;
int main(void) {
  string S, T;
  cin >> S >> T;
  vector<queue<lint>> alp(26, queue<lint>());
  for (lint i = 0; i < S.size(); i++) {
    alp[S[i] - 'a'].push(i);
  }
  lint cnt = 0;
  for (int i = 0; i < T.size(); i++) {
    int ch = T[i] - 'a';
    if (alp[ch].empty()) {
      cout << -1 << endl;
      return 0;
    }
    if (cnt > alp[ch].front()) {
      while (cnt > alp[ch].front()) {
        alp[ch].push(alp[ch].front() + S.size());
        alp[ch].pop();
      }
    }
    cnt = alp[ch].front();
    alp[ch].push(alp[ch].front() + S.size());
    alp[ch].pop();
  }
  cout << cnt + 1 << endl;
  return 0;
}
