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. NFS指定端口,NFS缓存(转载)

    nfs服务端: #编辑/etc/nfsmount.conf,在末尾添加: #RQUOTAD_PORT=30001#LOCKD_TCPPORT=30002#LOCKD_UDPPORT=30002#MOU ...

  2. 用 foreach()循环三维数组

    <?php $data = array( 0 => array( '中国' => 'china', '美国' => 'usa', '德国' => ' Germany', ...

  3. api 签名算法

    <?php define('token', 'tokensecret'); // 定义私钥token /** * 哈希验证签名 */ function hmacSign($array, $tok ...

  4. Django - Ajax基本内容整理

    将原来的请求结果普通字符串,变更为类字典的字符串 从这段代码中,可以看到,对原有函数,进行了一个try ...except....操作,进行异常捕捉,将捕捉过程及结果,存入在初始化的字典中,将字典通过 ...

  5. 16.2 【C# 5】调用者信息特性

    16.2.1 基本行为 .NET 4.5引入了三个新特性(attribute),即 CallerFilePathAttribute . CallerLineNumber- Attribute 和 Ca ...

  6. enote笔记语言(4)(ver0.4)——“5w1h2k”分析法

    章节:“5w1h2k”分析法   what:我想知道某个“关键词(keyword)”(即,词汇.词语,或称单词,可以是概念|专业术语|.......)的定义. why:我想分析and搞清楚弄明白“事物 ...

  7. Linux下源码安装Peach-2.3.8教程

    在peach文件夹下运行 python peach.py ./samples/HelloWorld.xml 提示先安装4Suite-XML. 根据提示在dependences文件夹下安装,出现两次错误 ...

  8. TensorFlow 学习笔记(2)----placeholder的使用

    此系列将会每日持续更新,欢迎关注 在TensorFlow中输入值的方式是通过placeholder来实现 例如:做两个数的乘法时,是先准备好两个place, 再将输出值定义成两数的乘法 最后利用ses ...

  9. 【模板】可持久化Treap

    洛谷3835 #include<cstdio> #include<algorithm> #include<cstdlib> #define ls (a[u].l) ...

  10. noip模拟赛 c

    分析:一道比较难的爆搜题.首先要把9个块的信息存下来,记录每个块上下左右位置的颜色,然后记录每一排每一列能否操作,之后就是bfs了.在bfs的时候用一个数记录状态,第i位表示原来的第i个块现在在哪个位 ...