using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;

namespace ConsoleApplication2
{
    class MyString
    {
        string abc = "abcdefghijklmnopqrstuvwxyz";
        int[] moji;
        int len;
        public MyString(string v)
        {
            len = v.Length;
            moji = new int[len];
            for (int i = 0; i < len; i++)
            {
                moji[i] = abc.IndexOf(v.Substring(i, 1));
            }
        }

        public int Length
        {
            get { return len; }
        }
        public int this[int i]
        {
            get { return moji[i]; }
        }

        public int IndexOf(int tar)
        {
            return IndexOf(tar, 0);
        }
        public int IndexOf(int tar, int startIndex)
        {
            for (int i = startIndex; i < len; i++)
            {
                if (tar == moji[i]) return i;
            }
            return -1;
        }
    }
    class Program
    {

        static void Main(string[] args)
        {
            string ss = Console.ReadLine();
            string tt = Console.ReadLine();
            MyString s = new MyString(ss);
            MyString t = new MyString(tt);

            int sl = s.Length;
            int n = t.Length;

            int[] find = new int[n];

            long ans = 0;

            find[0] = s.IndexOf(t[0]);
            ans = find[0];
            if (find[0] < 0)
            {
                ans = -1;
                Console.WriteLine(ans);
                return;
            }


            for (int i = 1; i < n; i++)
            {
                int f1 = s.IndexOf(t[i]);//最速
                if (f1 < 0)
                {
                    ans = -1;
                    Console.WriteLine(ans);
                    return;
                }
                int f2 = s.IndexOf(t[i], find[i - 1] + 1);//前の文字より後ろで最速
                //前の文字より後ろで見つかった場合
                if (f2 > -1)
                {
                    find[i] = f2;
                }
                else
                {
                    find[i] = f1;
                }
                if (find[i] > find[i - 1])
                {
                    ans += (find[i] - find[i - 1]);
                }
                else
                {
                    ans += sl - find[i - 1] + find[i];
                }
            }
            Console.WriteLine(ans+1);

        }
        

    }
}