#include <bits/stdc++.h>
using namespace std;
int main() {
  string s, t;
  cin >> s >> t;
  vector<bool> a(26);
  vector<int> c[26];
  for (int i = 0; i < (int)(s.size()); ++i) {
    a.at(s.at(i) - 'a') = true;
    c[s.at(i) - 'a'].push_back(i);
  }
  bool b = true;
  for (int i = 0; i < (int)(t.size()); ++i) {
    if (!a.at(t.at(i) - 'a')) {
      b = false;
      break;
    }
  }
  if (b) {
    long ans = 0;
    vector<int> d(t.size());
    int ch = 0;
    for (int i = 0; i < (int)(t.size()); ++i) {
      bool ch2 = false;
      for (int j = (ch); j < (int)(c[t.at(i) - 'a'].size()); j++) {
        d.at(i) = c[t.at(i) - 'a'].at(j);
        ch2 = true;
        ch = c[t.at(i) - 'a'].at(j);
      }
      if (!ch2) {
        d.at(i) = c[t.at(i) - 'a'].at(0);
        ch = c[t.at(i) - 'a'].at(0);
      }
    }
    int co = 0;
    for (int i = 0; i < (int)(t.size() - 1); ++i) {
      if (d.at(i) > d.at(i + 1)) {
        co++;
      }
    }
    ans = co * 7LL + d.at(t.size() - 1) + 1;
    cout << ans << endl;
  } else {
    cout << "-1" << endl;
  }
}
