#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

constexpr ll MOD = 1e9+7;
constexpr int INF = 1<<30;
constexpr ll  LINF = 1LL<<60;

#define Sort(x) sort(x.begin(),x.end())
#define Reverse(x) reverse(x.begin(),x.end())
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ll<<(n))

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

// a = (a+b)%MOD;
void addmod(ll& a, ll b) {
  a = (a+b)%MOD;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
    #define endl "\n"
  }
} before_main_function;

// ========== end of template ==========
string S, T;
vvi H(26);

// [0, e)
int find_last(int e, char c) {
  c = c -'a';
  const vi& arr = H[c];
  assert(!arr.empty());

  auto it = lower_bound(begin(arr), end(arr), e);
  if (it == begin(arr)) {
    return -1;
  }

  it--;
  return *it;
}

// [s, end)
int find_first(int s, char c) {
  c = c -'a';
  const vi& arr = H[c];
  assert(!arr.empty());

  auto it = lower_bound(begin(arr), end(arr), s);
  if (it == end(arr)) {
    return -1;
  }

  return *it;
}

struct Info {
  int index;
  int count;
  bool reset;
};

vector<Info> table;

int main(int argc, char** argv) {
  cin >> S >> T;

  // Make hash of S
  for (int i=0; i<int(S.size()); i++) {
    H[S[i]-'a'].push_back(i);
  }

  // validate
  for (auto c : T) {
    c = c - 'a';
    if (H[c].empty()) {
      cout << -1 << endl;
      return 0;
    }
  }

  // Make table
  table.resize(T.size());

  long m = 0;
  for (int i=0; i<int(T.size()); i++) {
    // continuation
    if (i>0) {
      int x = find_first(table[i-1].index+1, T[i]);
      if (x>=0) {
        table[i] = Info{x, 1, false};
        continue;
      }
    }
    // reset
    int x = find_first(0, T[i]);
    assert(x>=0);
    table[i] = Info{x, 1, true};
    m++;
  }

  cout << (m-1)*S.size() + table[T.size()-1].index+1 << endl;

  /*
  for (int i=T.size()-1; i>=1; i--) {
    if (!table[i].reset) continue;

    table[i-1].count += table[i].count;
  }

  int ti = 0;
  while (true) {
    Info info = table[ti];
    if (ti+info.count==int(T.size())) {
      int x = 0;
      for (; ti<int(T.size()); ti++) {
        x = find_first(x, T[ti]);
	assert(x>=0);
	x++;
      }
      cout << m*S.size()+x << endl;
      return 0;
    }

    ti += info.count;
    m++;
  }
  assert(false);
  */


  return 0;
}


Measured memory_bytes: 2256