#include <bits/stdc++.h>
using namespace std;
int zlis[26];
int zlit[26];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s, t;
  cin >> s >> t;
  int n = s.size();
  int m = t.size();
  for (int i = 0; i < n; i++) {
    zlis[s[i] - 97]++;
  }
  for (int i = 0; i < m; i++) {
    zlit[t[i] - 97]++;
  }
  for (int i = 0; i < 26; i++) {
    if (zlit[i] > 0 && zlis[i] == 0) {
      cout << -1;
      return 0;
    }
  }
  int p[n + 1][26];
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j < 26; j++) p[i][j] = -1;
  }
  for (int i = n - 1; i >= 0; i--) {
    if (i != (n - 1)) {
      for (int j = 0; j < 26; j++) {
        if (p[i + 1][j] >= i) p[i][j] = p[i + 1][j];
      }
    }
    p[i][s[i] - 97] = i;
  }
  int ob = 0;
  long long w = 0;
  for (int i = 0; i < m; i++) {
    int nr = t[i] - 97;
    if (i == (m - 1)) {
      if (p[ob][nr] != -1) {
        ob = p[ob][nr] + 1;
        w += ob;
        break;
      } else {
        w += n;
        ob = p[0][nr] + 1;
        w += ob;
        break;
      }
      break;
    }
    if (p[ob][nr] != -1) {
      ob = p[ob][nr] + 1;
      if (ob >= n) {
        w += n;
        ob = 0;
      }
    } else {
      w += n;
      ob = p[0][nr] + 1;
      if (ob >= n) {
        w += n;
        ob = 0;
      }
    }
  }
  cout << w;
}
