Mock CCC '19 Contest 2 J4 - Tudor Buys Some Cheesecake

View as PDF

Submit solution


Points: 4 (partial)
Time limit: 1.0s
Memory limit: 1G

Problem type

Tudor is planning a surprise, and needs to buy a cheesecake!

Having bought the cheesecake, Tudor wants to spell a message with the candles. Each candle is shaped in the form of one of the 26 letters of the English alphabet.

Tudor digs around in the DMOJ storage room and finds some candles that he can use. Given the candles he has and the message he wishes to spell, compute the minimum number of candles that Tudor needs to purchase in order to spell the message.

Constraints

1 \le |A|, |B| \le 10^6

In tests worth 5 marks, |A| \le 10^3 and |B| \le 10^3.

Input Specification

The input will consist of two lines.

The first line contains the string A, the message Tudor wants to spell.

The second line contains the string B, the candles Tudor currently has available to him.

These strings will only contain letters from the string ABCDEFGHIJKLMNOPQRSTUVWXYZ.

Output Specification

Output, on a single line, the number of candles Tudor needs to buy to spell the desired message.

Sample Input

BIRTHDAY
BDAY

Sample Output

4

Sample Explanation

Tudor, not wanting to resort to abbreviations, will need to buy an I, an R, a T, and an H in order to properly spell BIRTHDAY.


Comments

There are no comments at the moment.