/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+:---test
contest
son
---+/
/+---test
contest
programming
---+/
/+:---test
contest
sentence
---+/

void main(string[] args) {
  const S = readln.chomp;
  const T = readln.chomp;

  const Sn = S.length;

  long[][] chpos;
  chpos.length = 'z'-'a';
  foreach (i, c; S) {
    chpos[c-'a'] ~= i;
  }

  long ans;
  foreach (i, c; T) {
    const ans_m = ans%Sn;

    auto pos = chpos[c-'a'].assumeSorted;
    if (pos.length == 0) {
      "-1".writeln;
      return;
    }

    auto upper_pos = pos.upperBound(ans_m-1);
    if (upper_pos.length > 0) {
      ans += upper_pos[0] - ans_m;
    } else {
      ans += (Sn - ans_m) + pos[0];
    }
  }
  (ans+1).writeln;
}
