LCC ‘23 Contest 1 S2 - sdraC eht pilF

View as PDF

Submit solution


Points: 5
Time limit: 1.0s
Memory limit: 64M

Author:
Problem type

While Joshua has been out, came back, and is now busy counting and sorting his candy, Shane is stuck with <REDACTED> at her birthday party (yes, it's on Halloween)!

The two are playing a unique card game, where each card has two sides: one side has a random letter, the other has a random number. The rules of the game are very simple:

  • <REDACTED> will lay out the cards, one by one, each with either the letter OR number side facing up.
  • <REDACTED> tells Shane that every card with the letter L has the number N on the back.
  • Shane must then tell <REDACTED> a number X, the least number of cards he needs to flip to check if she is telling the truth.

Can you help Shane determine what number he should tell <REDACTED>?

Psst... stop <REDACTED> from coming up with more devious card games by solving the mystery on why mcpt.ca is running out of resources!

Constraints

1 \le C \le 10^5

L, L_i is an uppercase English letter.

1 \le N, N_i \le 9

Input Specification

The first line of input will contain the integer C, the number of cards in the deck.

The second line will contain C characters, representing the sides of the cards facing up. The i-th character represents the i-th card, and is either a number, N_i, or a letter, L_i.

The third and final line of input will contain L and N.

Output Specification

Output one integer, X, the least number of cards Shane needs to flip over to check if <REDACTED> is telling the truth.

Sample Input

5
A 4 D 9 2
A 2

Sample Output

3

Comments

There are no comments at the moment.