#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main() {
  string s, t;
  ll ans = -1;
  cin >> s >> t;
  for (int i = 0; i < t.size(); i++) {
    if (s.find(t[i], 0) == string::npos) {
      cout << ans << endl;
      return 0;
    }
  }
  ll loop = 0;
  int tmp = -1;
  for (int i = 0; i < t.size(); i++) {
    if (s.find(t[i], tmp + 1) == string::npos) {
      loop++;
      tmp = s.find(t[i], 0);
    } else {
      tmp = s.find(t[i], tmp + 1);
    }
  }
  cout << loop * s.size() + tmp+1;

  return 0;
}
