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

namespace ConsoleApplication2
{
    class StringWithSerchIndex
    {
        string moji;
        int len;
        Dictionary<char, List<int>> index;
        public StringWithSerchIndex(string v)
        {
            len = v.Length;
            moji = v;
        }
        public void makeIndex()
        {
            index = new Dictionary<char, List<int>>();
            for (int i = 0; i < len; i++)
            {
                if (!index.ContainsKey(moji[i]))
                {
                    index.Add(moji[i], new List<int>());
                }
                index[moji[i]].Add(i);
            }
        }

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

        public int IndexOf(char tar)
        {
            if (!index.ContainsKey(tar)) return -1;

            return index[tar][0];
        }
        public int IndexOf(char tar, int startIndex)
        {
            if (!index.ContainsKey(tar)) return -1;

            //startIndexより大きい最小の答えを２分探査で探す
            int min = 0;
            int max = index[tar].Count - 1;

            if (index[tar][max] < startIndex) return -1;
            if (index[tar][min] >= startIndex) return index[tar][min];

            while (true)
            {
                if (max - min < 2) return index[tar][max];
                int median = (min + max) / 2;

                if (index[tar][median] < startIndex)
                {
                    min = median;
                }
                else
                {
                    max = median;
                }
            }
        }
    }
    class Program
    {

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

            s.makeIndex();

            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);

        }
        

    }
}

Measured memory_bytes: 15456