#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, t;
  cin >> s >> t;
  map<int, int> m;
  vector<int> adj[27];
  for (int i = 0; i < s.size(); i++) {
    m[s[i] - 'a']++;
    adj[s[i] - 'a'].push_back(i);
  }
  for (int i = 0; i < t.size(); i++) {
    if (m[t[i] - 'a'] == 0) {
      cout << -1;
      return 0;
    }
  }
  int c[t.size() + 1], k = -1;
  for (int i = 0; i < t.size(); i++) {
    int curr = t[i] - 'a';
    if (adj[curr][adj[curr].size() - 1] > k) {
      for (int j = 0; j < adj[curr].size(); j++) {
        if (adj[curr][j] > k) {
          k = adj[curr][j];
          break;
        }
      }
    } else {
      k = adj[curr][0];
    }
    c[i] = k;
  }
  long long q = 0;
  k = -1;
  for (int i = 0; i < t.size(); i++) {
    if (c[i] <= k) {
      q += s.size();
    }
    k = c[i];
  }
  cout << q + k + 1;
}
