Problem description

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

The first line contains a single integer, n (2 ≤ n ≤ 2·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

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

Examples

Input

6
AFFAAA

Output

4

Input

3
AFI

Output

1

Note

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.

解题思路:每个玩家有两种状态:"ALLIN"或者"IN";只要当前玩家的状态不是"FOLDED",并且其他玩家的状态是"ALLIN"或者"FOLDED",那么当前玩家就可以将他的手放在桌子上,求将手放在桌子上的一共有几个玩家。做法:假设字符'A','F','I'出现的次数依次为a,f,i:①如果i==0,则字符串中只有'A'或'F',即将手放在桌子上的玩家人数为a;②如果i==1,当且仅当某位玩家的状态为"IN",则其他玩家的状态必定是'A'或者'F',即该玩家可以将手放在桌子上,人数为1;③如果i>1,则不满足条件,必定没有玩家的手放在桌子上,人数为0。

AC代码:

 #include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5+;
int n,a=,f=,i=;char s[maxn];
int main(){
cin>>n;getchar();
cin>>s;
for(int j=;j<n;++j){
if(s[j]=='A')a++;
else if(s[j]=='F')f++;
else i++;
}
if(i==)cout<<a<<endl;//如果没有I,则直接输出A的个数
else if(i==)cout<<<<endl;//i==1时,其他只有A或F,则此时只有一个人的手放在桌上
else cout<<<<endl;//否则不满足条件即为0个
return ;
}

B - Cows and Poker Game的更多相关文章

  1. Codeforces Round #174 (Div. 2)

    A. Cows and Primitive Roots 暴力. B. Cows and Poker Game 模拟. C. Cows and Sequence 线段树维护. D. Cow Progra ...

  2. Codeforces Round #174 (Div. 1 + Div. 2)

    A. Cows and Primitive Roots 暴力. B. Cows and Poker Game 模拟. C. Cows and Sequence 线段树维护. D. Cow Progra ...

  3. 洛谷P3078 [USACO13MAR]扑克牌型Poker Hands

    题目描述 Bessie and her friends are playing a unique version of poker involving a deck with \(N\) (\(1 \ ...

  4. P3078 [USACO13MAR]扑克牌型Poker Hands

    题目描述 Bessie and her friends are playing a unique version of poker involving a deck with N (1 <= N ...

  5. 【贪心 思维题】[USACO13MAR]扑克牌型Poker Hands

    看似区间数据结构的一道题 题目描述 Bessie and her friends are playing a unique version of poker involving a deck with ...

  6. 洛谷 P3078 [USACO13MAR]扑克牌型Poker Hands

    P3078 [USACO13MAR]扑克牌型Poker Hands 题目描述 Bessie and her friends are playing a unique version of poker ...

  7. USACO Poker Hands

    洛谷 P3078 [USACO13MAR]扑克牌型Poker Hands 题目传送门 JDOJ 2359: USACO 2013 Mar Silver 1.Poker Hands JDOJ传送门 题目 ...

  8. [LeetCode] Bulls and Cows 公母牛游戏

    You are playing the following Bulls and Cows game with your friend: You write a 4-digit secret numbe ...

  9. POJ 2186 Popular Cows(Targin缩点)

    传送门 Popular Cows Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 31808   Accepted: 1292 ...

随机推荐

  1. 2019 支付宝App支付 --- PHP

    SDK下载:https://docs.open.alipay.com/54/106370/;联系客服:https://cschannel.alipay.com/newPortal.htm?scene= ...

  2. Gym - 101611D Decoding of Varints(阅读理解题 )

    Decoding of Varints ​ 题意&思路: 首先根据红色边框部分的公式算出x,再有绿色部分得知,如果x是偶数则直接除以2,x是奇数则(x+1)/-2. PS:这题有数据会爆掉un ...

  3. 7-11 社交网络图中结点的“重要性”计算 (30 分)(Dijkstra算法)

    题意:  思路:对每个输入的点跑一遍dijkstra算法,然后对这个点到所有点的距离求和按公式输出就可以了. (这次尝试了用数组模拟链表来做最短路问题,刷新了自己对最短路的理解) 这里构造链表的过程我 ...

  4. Linux:在安装虚拟机时如何选择网络类型?

    如图所示工作站提供了5种网络模式,我们主要用的就是上面3种:桥接模式,NAT,仅主机 1,仅主机模式 仅主机模式:虚拟机用过vmnet1网卡与宿主机通信,但是不能与物理局域网内其他主机通信,可利用虚拟 ...

  5. Google Cloud SSH 连接配置

    设置当前用户及root用户的密码 sudo passwd xx-user # 输入新密码 sudo passwd root # 输入新密码(建议保持一样) 在本地生成私钥和公钥 cd ~/.ssh s ...

  6. scrapy——3 crawlSpider——爱问

    scrapy——3  crawlSpider crawlSpider 爬取一般网站常用的爬虫类.其定义了一些规则(rule)来提供跟进link的方便的机制. 也许该spider并不是完全适合您的特定网 ...

  7. Pycharm 的基本操作

    下载:https://www.jetbrains.com/pycharm/ 安装:随意安装在那个目录都可以 注册:可以采用 激活码 或者激活服务器,并对应在选项下面填入激活码或者激活服务器URL即可. ...

  8. ReatEasy+用户指南----第9章@MatrixParam

    转载说明出处:http://blog.csdn.net/nndtdx/article/details/6870391 原文地址 http://docs.jboss.org/resteasy/docs/ ...

  9. 对SPI、IIC、IIS、UART、CAN、SDIO、GPIO的解释

    SPI SPI(Serial Peripheral Interface:串行外设接口); SPI总线由三条信号线组成:串行时钟(SCLK).串行数据输出(SDO).串行数据输入(SDI).SPI总线可 ...

  10. JS 带运动的返回顶部 小案例

    带运动的返回顶部:当滚动条在滚动的时候,滚动鼠标的滚轮,应该让滚动条停止滚动,清掉定时器.下面的方法b 就是清掉的方法 <!DOCTYPE html PUBLIC "-//W3C//D ...