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

View as PDF

Submit solution

Points: 3 (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.


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


Sample Output


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.


  • -2
    Einstein100102  commented on Aug. 28, 2020, 2:25 p.m.

    what does the name error mean?

    • 1
      Kirito  commented on Aug. 28, 2020, 3:34 p.m.

      To quote the Python docs:

      Raised when a local or global name is not found. This applies only to unqualified names. The associated value is an error message that includes the name that could not be found.