const main = (input) => {
  var s = input[0];
  var t = input[1];

  var smap = {};
  for(var i=0;i<s.length;i++){
    var w = s[i];
    if(!smap[w])smap[w]=[];
    smap[w].push(i+1);
  }
  var ans = 0;
  var now = 0;
  for(var i=0;i<t.length;i++){
    var w = t[i];
    if(!smap[w] || smap[w].length == 0){ans = -1; break;}
    var idx = bsearch(smap[w], now+1);
    if(idx==-1){
      ans+=s.length;
      if(i==t.length-1){
        ans += smap[w][0];
      }else{
        now = smap[w][0];
      }
    }else{
      if(i==t.length-1){
        ans += smap[w][idx];
      }else{
        now = smap[w][idx];
      }
    }
  }
  console.log(ans);
}

function bsearch(arr, n){
  var a = 0;
  var b = arr.length-1;
  var ans = -1;
  while(a<=b){
    var ave = ~~((a+b)/2);
    if(arr[ave]<n){
      a = ave+1;
    }else{
      ans = Math.min(ans==-1?ave:ans,ave);
      b = ave-1;
    }
  }
  return ans;
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8').trim().split("\n"));
