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.
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.
import sys
import math
from sys import stdin, stdout
 
# TAKE INPUT
def get_ints_in_variables():
    return map(int, sys.stdin.readline().strip().split())
def get_int(): return int(input())
def get_ints_in_list(): return list(
    map(int, sys.stdin.readline().strip().split()))
def get_list_of_list(n): return [list(
    map(int, sys.stdin.readline().strip().split())) for _ in range(n)]
def get_string(): return sys.stdin.readline().strip()
 
def main():
    # Write Your Code Here
    n = input()
    m = input()
    mp  = {}
    for i in range(0, len(n)):
        if n[i] not in mp:
            mp[n[i]] = 1
        else:
            mp[n[i]] += 1

    
    mpm = {}
    for j in range(0, len(m)):
        if m[j] not in mp:
            print(-1)
            return
        else:
            if m[j] not in mpm:
                mpm[m[j]] = 1
            else:
                mpm[m[j]] += 1
    
    ans = 0
    for key, value in mpm.items():
        if mp[key] >= mpm[key]:
            ans += min(mp[key], mpm[key])
        else:
            ans += mp[key]
    print(ans)




#  calling main Function
if __name__ == "__main__":
    main()