using System;
class pg
 {
  static void Main(string[] args)
  {
    string s = Console.ReadLine();
    string t = Console.ReadLine(); 
    
    ulong count = 0;
    int offset = 0;
    int index = 0;
    foreach(char c in t)
    {
      index = s.IndexOf(c);
      if(index ==-1)
      {
        Console.WriteLine(-1);
        return;
      }
      else if(offset > index)
      {
        count ++;
      }
      offset = index;
    }
    ulong ret =count*(ulong)s.Length+ (ulong)index + 1;
 
    Console.WriteLine(ret);
  }
}