Once little Vasya read an article in a magazine on how to make beautiful handmade garland from colored paper. Vasya immediately went to the store and bought n colored sheets of paper, the area of each sheet is 1 square meter.

The garland must consist of exactly m pieces of colored paper of arbitrary area, each piece should be of a certain color. To make the garland, Vasya can arbitrarily cut his existing colored sheets into pieces. Vasya is not obliged to use all the sheets to make the garland.

Vasya wants the garland to be as attractive as possible, so he wants to maximize the total area of ​​m pieces of paper in the garland. Calculate what the maximum total area of ​​the pieces of paper in the garland Vasya can get.


-----Input-----

The first line contains a non-empty sequence of n (1 ≤ n ≤ 1000) small English letters ("a"..."z"). Each letter means that Vasya has a sheet of paper of the corresponding color.

The second line contains a non-empty sequence of m (1 ≤ m ≤ 1000) small English letters that correspond to the colors of the pieces of paper in the garland that Vasya wants to make.


-----Output-----

Print an integer that is the maximum possible total area of the pieces of paper in the garland Vasya wants to get or -1, if it is impossible to make the garland from the sheets he's got. It is guaranteed that the answer is always an integer.


-----Examples-----
Input
aaabbac
aabbccac

Output
6

Input
a
z

Output
-1


-----Note-----

In the first test sample Vasya can make an garland of area 6: he can use both sheets of color b, three (but not four) sheets of color a and cut a single sheet of color c in three, for example, equal pieces. Vasya can use the resulting pieces to make a garland of area 6.

In the second test sample Vasya cannot make a garland at all — he doesn't have a sheet of color z.

Difficulty: interview

Starter code:

Solutions:
n = input().rstrip()
m = input().rstrip()
cnt1 = [0] * 26
cnt2 = [0] * 26
for i in n:
    cnt1[ord(i) - ord("a")] += 1
for i in m:
    cnt2[ord(i) - ord("a")] += 1
res = 0
for i in range(26):
    a1 = cnt1[i]
    a2 = cnt2[i]
    if a1 == 0 and a2 != 0:
        print(-1)
        return
    res += min(a1, a2)
print(res)

s=input().strip()
m=input().strip()
c1=[0]*26
c2=[0]*26
for i in s:
    c1[ord(i)-ord('a')]+=1
for i in m:
    c2[ord(i)-ord('a')]+=1
ans=0
for i in range(26):
    if c1[i]==0 and c2[i]!=0:
        print(-1)
        return
    ans+=min(c1[i],c2[i])
print(ans)

has = input()
need = input()
A, B = [0] * 26, [0] * 26
for i in has:
    A[ord(i)-97] += 1
for i in need:
    B[ord(i)-97] += 1
result = 0
for i in range(26):
    if not A[i] and B[i]:
        result = -1
        break
    else:
        result += min(A[i], B[i])
print(result)


colors = list(input())
colors.sort()
wants = list(input())
wants.sort()

res = 0

hecan = 1
for c in wants:
    if c not in colors:
        hecan = 0

ca = sorted(set(colors))
wa = sorted(set(colors))

for c in ca:
    if colors.count(c) >= wants.count(c):
        res += wants.count(c)
    else:
        res += colors.count(c)
    #print(colors.count(c), wants.count(c))

if hecan == 0:
    print(-1)
else:
    print(res)


n = input()
m = input()
c = set(m)
ans = 0
for colour in c:
    nc = n.count(colour)
    mc = m.count(colour)
    if nc == 0:
        ans = -1
        break
    else:
        ans += min(nc, mc)
print(ans)

import sys
#sys.stdin = open('input.txt', 'r')
n = input()
m = input()
N = dict()
M = dict()
for k in set(n):
	N.update({k : n.count(k)})
for k in set(m):
	M.update({k : m.count(k)})
S = 0
for k in M:
	if k in N:
		if N[k] >= M[k]:
			S += M[k]
		else:
			S += N[k]
	else:
		print(-1)
		return
print(S)

	


a=input()
b=input()
ans=0
for i in range(ord('a'),ord('z')+1):
    num1=sum(ord(j)==i for j in a)
    num2=sum(ord(j)==i for j in b)
    ans+=min(num1,num2)
    if num2>0 and num1==0:
        print(-1)
        break;
else:
    print(ans)



n = input()
m = input()
# n = 'aaabbac'
# m = 'aabbccac'

N = {}
for c in n:
    if c in N:
        N[c] += 1
    else:
        N[c] = 1

M = {}
for c in m:
    if c in M:
        M[c] += 1
    else:
        M[c] = 1

#print('N: ', N)
#print('M: ', M)

S = 0

for color, count in list(M.items()):
    if color not in N:
        S = -1
        break
    else:
        S += min(count, N[color])

print(S)


sheet = input()
garland = input()
sheetnum = dict()
garlandnum = dict()

for color in sheet:
	if not color in sheetnum:
		sheetnum[color] = 1
	else:
		sheetnum[color] = sheetnum[color] + 1

for color in garland:
	if not color in garlandnum:
		garlandnum[color] = 1
	else:
		garlandnum[color] = garlandnum[color] + 1

ans = 0
for color in list(garlandnum.keys()):
	if not color in sheetnum:
		ans = -1
		break
	if garlandnum[color] >= sheetnum[color]:
		ans = ans + sheetnum[color]
	else:
		ans = ans + garlandnum[color]

print(ans)
	
	



a=input()
b=input()
dict1={}
dict2={}
for i in range (0,len(a)):
    if a[i] in dict1:
        dict1[a[i]]+=1
    else:
        dict1[a[i]]=1

act=set()
for j in range (0,len(b)):
    act.add(b[j])
    if b[j] in dict2:
        dict2[b[j]]+=1
    else:
        dict2[b[j]]=1
        if (b[j] not in dict1):
            dict1[b[j]]=0


z=list(act)
ctr=0
char=0
for i in range (0,len(z)):
    ctr+=min(dict1[z[i]],dict2[z[i]])
    if (min(dict1[z[i]],dict2[z[i]])!=0):
        char+=1

if (ctr>0 and char==len(z)):
    print (ctr)
else:
    print(-1)
    
        
        
    
    


a = input()
b = input()
s = 0
ok = True
for i in range(27):
    c = chr(ord('a') + i)
    aa = a.count(c)
    bb = b.count(c)
    m = min(a.count(c), b.count(c))
    if aa == 0 and bb != 0:
        ok = False
    s = s + m
if not ok:
    print(-1)
else:
    print(s)


n, m = input(), input()
ms = set(m)
ans = 0
for k in ms:
    if not n.__contains__(k):
        ans = -1
        break
    if n.count(k) >= m.count(k):
        ans += m.count(k)
    else:
        ans += n.count(k)
print(ans)

import sys
have = input()
need = input()
pl = 0
alph = "abcdefghijklmnopqrstuvwxyz"
for l in alph:
    if l in need:
        if l not in have:
            print(-1)
            return
        pl += min(have.count(l), need.count(l))
print(pl)

def game():
    n = input()
    m = input()
    nlist = []
    mlist = []
    for i in range(len(n)):
        nlist.append(n[i])
    for i in range(len(m)):
        mlist.append(m[i])
    counter = 0
    for i in range(len(m)):
        if not m[i] in n:
            print(-1)
            return 1
    for i in range(len(m)):
        if m[i] in nlist:
            counter += 1
            mlist[i:i + 1] = []
            nlist[nlist.index(m[i])] = []
    print(counter)
game()


import sys
colors = input()
finish_colors = input()
result = 0
differnt_finish_colors = set(finish_colors)
tested_colors = []
for color in differnt_finish_colors:
    if not (color in tested_colors):
        if not colors.count(color):
            print('-1')
            return
        else:
            result += min([colors.count(color), finish_colors.count(color)])
print(result)

colour = input()
new_colour = input()
sum = 0
k = 0
list = []
for i in new_colour:
    if i not in list:
        list += i
for i in list:
    a = colour.count(i)  
    b = new_colour.count(i) 
    if a > b:
        sum += b
    else:
        sum += a
    if i not in colour:
        k += 1
if k > 0:
    print(-1)
else:
    print(sum)


our_list_1 = list(map(str, input()))
our_list_3 = (list(map(str, input())))
our_list_2 = list(set(our_list_3))
output = 0
for i in range(len(our_list_2)):
    if our_list_2[i] not in our_list_1:
        print(-1)
        break  
    output += min(our_list_3.count(our_list_2[i]), our_list_1.count(our_list_2[i]))
    if i == len(our_list_2) - 1:
        print(output)


def main():
    import sys
    material = input()
    scheme = input()
    flag = True
    for i in range(len(scheme)):
        if flag:
            if not scheme[i] in material:
                print(-1)
                flag = False
    if flag:
        counter = 0
        SIZE = len(scheme) - 1
        saver = []
        result = 0
        while counter <= SIZE:
            saver += [scheme[counter]]
            if (scheme.count(scheme[counter]) <=
                material.count(scheme[counter])):
                result += scheme.count(scheme[counter])
            else:
                result += material.count(scheme[counter])
            while scheme[counter] in saver:
                if counter < SIZE:
                    counter += 1
                else:
                    print(result)
                    return
        print(result)

main()

from collections import defaultdict
s, a, b = 0, defaultdict(int), defaultdict(int)
for i in input(): a[i] += 1
for i in input(): b[i] += 1
for i in b:
    if i in a: s += min(a[i], b[i])
    else:
        s = -1
        break
print(s)

def count(s):
    c = [0]*26
    for t in s:
        c[ord(t)-ord('a')]+=1
    return c
c1 = count(input())
c2 = count(input())
valid = True
result = 0
for i in range(26):
    if c2[i]>0 and c1[i]==0:
        valid = False
    result += min(c1[i], c2[i])
if not valid:
    print(-1)
else:
    print(result)


a = input()
b = input()
x = [0] * 26
y = [0] * 26
for c in a:
  x[ord(c) - ord('a')] += 1
for c in b:
  y[ord(c) - ord('a')] += 1
result = 0
for i in range(26):
  if x[i] == 0 and y[i] > 0:
    result = -1
    break
  result += min(x[i], y[i])
print(result)

import sys
s = input()
s1 = input()
ans = 0
x = [0] * 27
y = [0] * 27
for i in range(len(s)):
    x[ord(s[i]) - 97]+=1
for i in range(len(s1)):
    y[ord(s1[i]) - 97] += 1
for i in range(27):
    if x[i] == 0 and y[i] != 0:
        print(-1)
        return
    ans += min(x[i], y[i])
print(ans)

n = input()
m = input()
s = set(m)
area = 0
for i in s:
    a1 = n.count(i)
    a2 = m.count(i)
    if a1 == 0:
        area = -1
        break
    elif a1 >= a2:
        area += a2
    else:
        area += a1
print(area)


import sys
import math
  
n = sys.stdin.readline()
m = sys.stdin.readline()

kn = [0] * 26
km = [0] * 26
for i in n:
    if(i != "\n"):
        kn[ord(i) - ord('a')] += 1
 
for i in m:
    if(i != "\n"):
        km[ord(i) - ord('a')] += 1      
        
res = 0
for i in range(26):
    v = min(kn[i], km[i])
    if(kn[i] == 0 and km[i] > 0):
        print(-1)
        return
    
    res += v    
  
print(res)  


'''
Created on Feb 13, 2015

@author: mohamed265
'''
a1 = input()
a2 = input()
slon = 0
for i in range(ord('a') , ord('z') + 1):
    x = chr(i)
    count1 = a1.count(x)
    count2 = a2.count(x)
    if count1 == 0 and count2 != 0:
        print(-1)
        return
    else:
        if count1 >= count2:
            slon += count2
        else:
            slon += count1
print(slon)