#include <bits/stdc++.h>
using namespace std;
int main() {
  long long j, k = 0, x = 0, y = 0, i, ans;
  string s1, s2;
  cin >> s1 >> s2;
  long long n1 = s1.size();
  long long n2 = s2.size();
  bool b[26] = {0};
  for (i = 0; i < n1; i++) b[s1[i] - 'a'] = 1;
  for (i = 0; i < n2; i++)
    if (b[s2[i] - 'a'] == 0) return cout << -1, 0;
  ;
  vector<long long> a[26];
  long long bb[n2], cnt[26] = {0};
  for (i = 0; i < n1; i++) {
    a[s1[i] - 'a'].push_back(i + 1);
  }
  char c = s2[0] - 'a';
  bb[0] = a[c][(cnt[c]) % a[c].size()];
  cnt[c]++;
  for (i = 1; i < n2; i++) {
    char c = s2[i] - 'a';
    x = a[c][(cnt[c]) % a[c].size()];
    if (x <= bb[i - 1]) {
      y++;
      memset(cnt, 0, sizeof(cnt));
    }
    bb[i] = x;
    cnt[c]++;
  }
  cout << y * n1 + bb[n2 - 1];
}
