import std.stdio, std.conv, std.string, std.range, std.algorithm, std.array, std.functional;

void main() {
  auto s = readln.chomp;
  auto t = readln.chomp;

  auto idx = new ulong[][256];
  foreach(i, c; s) {
    idx[c] ~= 1 + i;
  }

  long f() {
    ulong l,j;
    foreach(c; t) {
      if(idx[c].length == 0) return -1;
      auto a = assumeSorted(idx[c]).upperBound(j);
      if(!a.empty) {
        j = a.front;
      } else {
        l++;
        j = idx[c].front;
      }
    }
    return l * s.length + j;
  }

  f().writeln;
}
