3678.Cows and Poker Game

Time Limit: 1s Memory Limit: 256MB

There are n cows playing poker at a table. For the current betting phase, each player's status is either "ALLIN", "IN", or "FOLDED", and does not change throughout the phase. To increase the suspense, a player whose current status is not "FOLDED" may show his/her hand to the table. However, so as not to affect any betting decisions, he/she may only do so if all other players have a status of either "ALLIN" or "FOLDED". The player's own status may be either "ALLIN" or "IN".

Find the number of cows that can currently show their hands without affecting any betting decisions.

Input Format(From the terminal/stdin)

The first line contains a single integer, n (2 \le n \le 2 \cdot 105). The second line contains n characters, each either "A", "I", or "F". The i-th character is "A" if the i-th player's status is "ALLIN", "I" if the i-th player's status is "IN", or "F" if the i-th player's status is "FOLDED".

Output Format(To the terminal/stdout)

The first line should contain a single integer denoting the number of players that can currently show their hands.

Sample Input 1

Copy
6
AFFAAA
 \n
      \n

Sample Output 1

Copy
4
 \n

Sample Input 2

Copy
3
AFI
 \n
   \n

Sample Output 2

Copy
1
 \n

Hints

In the first sample, cows 1, 4, 5, and 6 can show their hands. In the second sample, only cow 3 can show her hand.

Submit

请先 登录

© 2025 FAQs