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.
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 14 16:13:39 2023

@author: pc
"""
def max_garland_area(available_colors, required_colors):
    available_count = {}
    required_count = {}
    
    # Count the available sheets of each color
    for color in available_colors:
        available_count[color] = available_count.get(color, 0) + 1
    
    # Count the required sheets of each color
    for color in required_colors:
        required_count[color] = required_count.get(color, 0) + 1
    
    max_area = 0
    
    # Calculate the maximum possible total area
    for color in required_count:
        if color not in available_count:
            return -1
        max_area += min(available_count[color], required_count[color])
    
    return max_area

# Read input
available_colors = input().strip()
required_colors = input().strip()

# Calculate and print the result
result = max_garland_area(available_colors, required_colors)
print(result)
