output_description: If there exists an integer i satisfying the following condition, print the
  minimum such i; otherwise, print `-1`.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      s
      t
attempt: # -*- coding: utf-8 -*-
  import sys
  
  # sys.setrecursionlimit(10**6)
  # buff_readline = sys.stdin.buffer.readline
  buff_readline = sys.stdin.readline
  readline = sys.stdin.readline
  
  INF = 2**62 - 1
  
  
  def read_int():
      return int(buff_readline())
  
  
  def read_int_n():
      return list(map(int, buff_readline().split()))
  
  
  def read_float():
      return float(buff_readline())
  
  
  def read_float_n():
      return list(map(float, buff_readline().split()))
  
  
  def read_str():
      return readline().strip()
  
  
  def read_str_n():
      return readline().strip().split()
  
  
  def error_print(*args):
      print(*args, file=sys.stderr)
  
  
  def mt(f):
      import time
  
      def wrap(*args, **kwargs):
          s = time.time()
          ret = f(*args, **kwargs)
          e = time.time()
  
          error_print(e - s, "sec")
          return ret
  
      return wrap
  
  
  class Mod:
      def __init__(self, m):
          self.m = m
  
      def add(self, a, b):
          return (a + b) % self.m
  
      def sub(self, a, b):
          return (a - b) % self.m
  
      def mul(self, a, b):
          return ((a % self.m) * (b % self.m)) % self.m
  
      def div(self, a, b):
          return self.mul(a, pow(b, self.m - 2, self.m))
  
      def pow(self, a, b):
          return pow(a, b, self.m)
  
  
  @mt
  def slv(S, T):
      if len(set(c for c in T) - set(c for c in S)) > 0:
          return -1
  
      from collections import defaultdict
  
      si = defaultdict(list)
      for i, c in enumerate(S):
          si[c].append(i)
  
      ans = 0
      ci = 0
      from bisect import bisect_left
  
      for i, c in enumerate(T):
          j = bisect_left(si[c], ci)
          if j == len(si[c]):
              j = 0
              ans += 1
          ci = si[c][j] + 1
      return (ans) * len(S) + ci
  
  
  def main():
      S = read_str()
      T = read_str()
      print(slv(S, T))
  
  
  if __name__ == "__main__":
      main()
  
problem_description: Statement
  
  Given are two strings s and t consisting of lowercase English letters.
  Determine if there exists an integer i satisfying the following condition, and
  find the minimum such i if it exists.
  
    * Let s' be the concatenation of 10^{100} copies of s. t is a subsequence of the string {s'}_1{s'}_2\ldots{s'}_i (the first i characters in s').
samples: [{"input": "contest\n    son", "output": "10\n    \n\nt = `son` is a subsequence of the string `contestcon` (the first 10 characters\nin s' = `contestcontestcontest...`), so i = 10 satisfies the condition.\n\nOn the other hand, t is not a subsequence of the string `contestco` (the first\n9 characters in s'), so i = 9 does not satisfy the condition.\n\nSimilarly, any integer less than 9 does not satisfy the condition, either.\nThus, the minimum integer i satisfying the condition is 10.\n\n* * *"}, {"input": "contest\n    programming", "output": "-1\n    \n\nt = `programming` is not a substring of s' = `contestcontestcontest...`. Thus,\nthere is no integer i satisfying the condition.\n\n* * *"}, {"input": "contest\n    sentence", "output": "33\n    \n\nNote that the answer may not fit into a 32-bit integer type, though we cannot\nput such a case here."}]