#include <bits/stdc++.h>
using namespace std;
const int prime = 999983;
const int INF = 0x7FFFFFFF;
const long long INFF = 0x7FFFFFFFFFFFFFFF;
const double pi = acos(-1.0);
const double inf = 1e18;
const double eps = 1e-6;
const long long mod = 1e9 + 7;
long long qpow(long long a, long long b) {
  long long s = 1;
  while (b > 0) {
    if (b & 1) s = s * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return s;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
int dr[2][4] = {1, -1, 0, 0, 0, 0, -1, 1};
const int maxn = 1e5 + 10;
char ar[maxn], br[maxn], cr[2 * maxn];
int nxt[maxn * 2][27];
int main(void) {
  cin >> ar >> br;
  int n = strlen(ar);
  int m = strlen(br);
  for (int i = 0; i < n; ++i) cr[i] = cr[i + n] = ar[i];
  for (int i = 2 * n - 1; i >= 0; --i) {
    for (int j = 0; j < 26; ++j) nxt[i][j] = nxt[i + 1][j];
    nxt[i][cr[i] - 'a'] = i;
  }
  long long ans = 0;
  int j = 0;
  for (int i = 0; i < m; ++i) {
    if (nxt[j][br[i] - 'a'] == 0) {
      ans = -1;
      break;
    }
    int t = nxt[j][br[i] - 'a'];
    ans += t - j + 1;
    j = (t + 1) % n;
  }
  cout << ans << endl;
  return 0;
}
