console.log((args=>{
  const [s,t] = args.trim().split`\n`;
  const c = Array.from({length:26},_=>[]);
  const sl = s.length, tl = t.length;
  for ( let i = 0; i < sl; i++ ) c[s.charCodeAt(i)-97].push(i);
  const o = Array(26).fill(0);
  let i = -1, cyc = 0;
  for ( let j = 0; j < tl; j++ ) {
    const tc = t.charCodeAt(j)-97;
    const l = c[tc].length;
    if (!l) return '-1';
    if ( l <= o[tc] ) o[tc] = 0;
    const k = cyc * sl + c[tc][o[tc]];
    o[tc]++;
    if ( i < k ) i = k;
    else {
      cyc++;
      i = cyc * sl + c[tc][0];
      o[tc] = 0;
    }
  }
  return `${i+1}`;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));
