#include <bits/stdc++.h>
const int N = 1e6 + 10;
const int mod = 998244353;
using namespace std;
int get_second(pair<int, int> i) { return i.second; }
long long power(long long x, long long y) {
  int res = 1;
  x = x % mod;
  while (y > 0) {
    if (y & 1) res = (res * x) % mod;
    y = y >> 1;
    x = (x * x) % mod;
  }
  return res;
}
int trail_zero(int n) {
  while (n % 10 == 0) n /= 10;
  return n;
}
map<long long, long long> m1;
set<long long> set1;
set<long long> st;
multiset<long long> s1;
map<pair<long long, long long>, long long> mx;
vector<pair<long long, long long>> vx;
vector<pair<pair<long long, long long>, long long>> vz;
vector<long long> val;
vector<pair<long long, long long>> val2;
map<char, int> m2;
char s111[N];
long long p2[N], p3[N];
bool vis[N];
string second[N];
long long h, k, g, x, ans = 1, q, t, cnt = 0, d = 0, ansx = 1e18, n, m;
stack<int> sx;
queue<int> qx;
inline bool in(int x, int y) {
  return 1 <= x && x < n + 1 && 1 <= y && y < m + 1;
}
inline bool in2(int x, int y) { return 0 <= x && x < n && 0 <= y && y < m; }
bool check(int i, int j) {
  if (second[i][j] == '.')
    return true;
  else
    return false;
}
long long count_divisor(long long a) {
  long long cnt = 0;
  for (long long i = 1; i * i <= a; i++) {
    if (a % i == 0) {
      if (a / i != i)
        cnt += 2;
      else
        cnt += 1;
    }
  }
  return cnt;
}
void primeFactors(long long n) {
  while (n % 2 == 0) {
    st.insert(2);
    n = n / 2;
  }
  for (long long i = 3; i <= sqrt(n); i = i + 2) {
    while (n % i == 0) {
      st.insert(i);
      n = n / i;
    }
  }
  if (n > 2) st.insert(n);
}
int pref[N], suff[N];
vector<vector<long long>> alp(26);
int a[2][505][505];
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  srand(time(NULL));
  ;
  string second, t;
  cin >> second >> t;
  for (int i = 0; i < second.size(); i++)
    alp[second[i] - 'a'].emplace_back(i + 1);
  long long index = 0, ans = 0;
  for (long long i = 0; i < t.size(); i++) {
    if (alp[t[i] - 'a'].size() == 0) return cout << "-1", 0;
    long long temp =
        upper_bound(alp[t[i] - 'a'].begin(), alp[t[i] - 'a'].end(), index) -
        alp[t[i] - 'a'].begin();
    if (temp == alp[t[i] - 'a'].size()) temp = 0;
    long long y = alp[t[i] - 'a'][temp];
    if (index < y)
      ans += (y - index);
    else {
      ans += y;
      ans += (second.size() - index);
    }
    index = y;
  }
  cout << ans;
}
