Buggy python submission (verdict: Time Limit Exceeded):
s = input()
t = input()

c=0
j=-1
k=1

a=len(s)

for i in range(0,len(t)):
  while True:
    j=j+1
    c=c+1

    if j>=a:
      j=0

    if t[i:i+1]==s[j:j+1]:
      k=1
      break
    else:
      k=k+1
      if k>a+1:
        print("-1")
        exit()
print(c)


Fixed submission:
s = input()
t = input()

x = len(s)
y = len(t)

a = 0
b = x
c = 0
a0 = 0


for i in range(0,y):
  while True:
    #先頭からの位置
    a=s.find(t[i:i+1],a0)+1
    if a <= 0:
      a=s.find(t[i:i+1])+1
    if a <= 0:
      print("-1")
      exit()
    
    if a<=a0:
      c=c+a+b
    else:
      c=c+a-a0
    b=x-a
    a0=a
    break
    
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
t = input()

c=0
j=-1
k=1

#print(len(s))

#t
for i in range(0,len(t)):
  while True:
    j=j+1
    c=c+1

    if j>=len(s):
#      print("折り返し")
#      print(j)
      #jがお尻まで行ったら先頭に戻る
      j=0

#    print(j)
#    print(c)
    
    if t[i:i+1]==s[j:j+1]:
#      print("hit")
      #kはもう一度一文字めからカウントし直し
      k=1
      break
    else:
      #hitしなかった場合、index　カウントアップ
      k=k+1
      #一周回ってもヒットしなかったらエラー
      if k>len(s)+1:
        print("-1")
        exit()
print(c)


Fixed submission:
s = input()
t = input()

x = len(s)
y = len(t)

a = 0
b = x
c = 0
a0 = 0


for i in range(0,y):
  while True:
    #先頭からの位置
    a=s.find(t[i:i+1],a0)+1
    if a <= 0:
      a=s.find(t[i:i+1])+1
    if a <= 0:
      print("-1")
      exit()
    
    if a<=a0:
      c=c+a+b
    else:
      c=c+a-a0
    b=x-a
    a0=a
    break
    
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
t = input()

c=0
j=0
k=0

#t
for i in range(0,len(t)):
  while True:
    if t[i:i+1]==s[j:j+1]:
      j=j+1
      c=c+1
      k=c
      break
    else:
      if j==len(s):
        j=0
      else:
        if c-k==len(s):
          print("-1")
          exit()
        else:
          j=j+1
          c=c+1
print(c)

Fixed submission:
s = input()
t = input()

x = len(s)
y = len(t)

a = 0
b = x
c = 0
a0 = 0


for i in range(0,y):
  while True:
    #先頭からの位置
    a=s.find(t[i:i+1],a0)+1
    if a <= 0:
      a=s.find(t[i:i+1])+1
    if a <= 0:
      print("-1")
      exit()
    
    if a<=a0:
      c=c+a+b
    else:
      c=c+a-a0
    b=x-a
    a0=a
    break
    
print(c)

Buggy python submission (verdict: Runtime Error):
s = input()
t = input()

c=1
j=0
k=0

#t
for i in range(0,len(t)):
  while True:
    if t[i:i+1]==s[j:j+1]:
      J=J+1
      k=0
      break
    else:
      if j==len(s):
        j=0
      else:
        j=j+1
        k=k+1
        c=c+1
        if k+1==len(s):
          print("-1")
          exit()
        else:
          j=j+1
          k=k+1
          c=c+1
print(c)


Fixed submission:
s = input()
t = input()

x = len(s)
y = len(t)

a = 0
b = x
c = 0
a0 = 0


for i in range(0,y):
  while True:
    #先頭からの位置
    a=s.find(t[i:i+1],a0)+1
    if a <= 0:
      a=s.find(t[i:i+1])+1
    if a <= 0:
      print("-1")
      exit()
    
    if a<=a0:
      c=c+a+b
    else:
      c=c+a-a0
    b=x-a
    a0=a
    break
    
print(c)

Buggy python submission (verdict: Runtime Error):
s = input()
t = input()

c=1
j=0
k=0

#t
for i in range(0,len(t)):
  flag = 0
  while True:
    if t[i:i+1]==s[j:j+1]:
      J=J+1
      k=0
      break
    else:
      if j==len(s):
        j=0
      else:
        j=j+1
        k=k+1
        c=c+1
        if k+1==len(s):
          print("-1")
          exit()
        else:
          j=j+1
          k=k+1
          c=c+1
print(c)


Fixed submission:
s = input()
t = input()

x = len(s)
y = len(t)

a = 0
b = x
c = 0
a0 = 0


for i in range(0,y):
  while True:
    #先頭からの位置
    a=s.find(t[i:i+1],a0)+1
    if a <= 0:
      a=s.find(t[i:i+1])+1
    if a <= 0:
      print("-1")
      exit()
    
    if a<=a0:
      c=c+a+b
    else:
      c=c+a-a0
    b=x-a
    a0=a
    break
    
print(c)

Buggy python submission (verdict: Runtime Error):
s = input()
t = input()

c=1
j=0
k=0

flag = 0

#t
for i in range(0,len(t)):
  print("i",i)
  flag = 0
  while True:
    print("j",j) 
    if t[i:i+1]==s[j:j+1]:
      J=J+1
      flag = 1
      k=0
      break
    else:
      if j==len(s):
        j=0
      else:
        j=j+1
        k=k+1
        c=c+1
        if k+1==len(s):
          print("-1")
          exit()
        else:
          j=j+1
          k=k+1
          c=c+1
print(c)

Fixed submission:
s = input()
t = input()

x = len(s)
y = len(t)

a = 0
b = x
c = 0
a0 = 0


for i in range(0,y):
  while True:
    #先頭からの位置
    a=s.find(t[i:i+1],a0)+1
    if a <= 0:
      a=s.find(t[i:i+1])+1
    if a <= 0:
      print("-1")
      exit()
    
    if a<=a0:
      c=c+a+b
    else:
      c=c+a-a0
    b=x-a
    a0=a
    break
    
print(c)