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. CPU指令、机器码、程序和汇编语言

    一.指令 指令就是指挥机器工作的指示和命令.控制器靠指令指挥机器工作,人们用指令表达自己的意图,并交给控制器执行.一台计算机所能执行的各种不同指令的全体,叫做计算机的指令系统或指令集,每一台计算机均有 ...

  2. servlet之@PostConstruct,@PreDestroy

    1.@PostConstruct说明 被@PostConstruct修饰的方法会在服务器加载Servlet的时候运行,并且只会被服务器调用一次,类似于Serclet的inti()方法.被@PostCo ...

  3. 【LeetCode】2、Add Two Numbers

    题目等级:Medium 题目描述:   You are given two non-empty linked lists representing two non-negative integers. ...

  4. Linux之网络ping(unknown host)故障及yum no more mirrors to try

    1.ping外网出现ping:unknown host   字样故障 鉴于网上大多都是提供临时生效的解决办法,这里不再赘述,并提供下永久生效的方案: 永久生效: 1)添加DNS地址和下一跳网关地址至网 ...

  5. PAT 1114 Family Property

    This time, you are supposed to help us collect the data for family-owned property. Given each person ...

  6. 【codeforces 515D】Drazil and Tiles

    [题目链接]:http://codeforces.com/contest/515/problem/D [题意] 给你一个n*m的格子; 然后让你用1*2的长方形去填格子的空缺; 如果有填满的方案且方案 ...

  7. Spring Cloud 之 Cookie 丢失 与 Host 传递

    通过spring zuul 代理至后台,写入Cookie发现无法写入,到浏览器中,和无法获取Domain域名 通过长时间的度娘和求助别人发现:Spring-zuul  需要加入以下配置 zuul.se ...

  8. 20180620关于使用xtrabackup热还原数据库

    参看:http://www.cnblogs.com/waynechou/p/xtrabackup_backup.html http://www.cnblogs.com/waynechou/p/xtra ...

  9. MySQL系列:innodb源码分析 图 ---zerok的专栏

    http://blog.csdn.net/yuanrxdu/article/details/40985363

  10. Rails 教程

    Rails 教程 http://web.siwei.tech/ http://www.siwei.me/