s=input()
f=input()
s=s[0:len(s)-1] #截掉最后的.
list=s.split()
c=0
flag = 0
for i in range(0,len(list)):
    c = c + len(list[i])
    if list[i]==f:
        flag=1
        print(i+1)
        break

if flag==0: print(c)
/**************************************************************
	Problem: 1012
	User: admin
	Language: Python
	Result: Accepted
	Time:89 ms
	Memory:34480 kb
****************************************************************/