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. CAD从线型文件加载线型记录(com接口)

    主要用到函数说明: _DMxDrawX::LoadLinetypeFromFile 从线型文件加载线型记录,详细说明如下: 参数 说明 BSTR pszLinetypeFile 线型文件名,支持htt ...

  2. demo__webpack

    webpack 中使用的包更新非常频繁,使用方式可能很快就会改变,解决方式 看webapck文档 和 包的使用文档 看包的源码 其他... 环境 win10 + webstorm 2019.1.3 + ...

  3. C - CJSON

    cJSON   API 说明 cJSON_Version() 获得cJSON的版本 cJSON_InitHooks(); 初始化cJSON_Hooks结构体 cJSON_Parse(); 将字符串解析 ...

  4. 5.terms搜索多个值以及多值搜索结果优化

    主要知识点 terms搜索多个值,并和term的比较     一.term和terms terms是在这个字段中搜索多个值,相当于sql中的in语法 (select * from tbl where ...

  5. CentOS与FreeBSD环境下安装filebeat

    业务服务器CentOS与FreeBSD共存(痛苦囧...) CentOS rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch ...

  6. 《零压力学Python》 之 第四章知识点归纳

    第四章(决策和循环)知识点归纳 if condition: indented_statements [ elif condition: Indented_statements] [else: Inde ...

  7. RSAROLL

    题目:http://www.shiyanbar.com/ctf/1918 # -*- coding: utf-8 -*- import gmpy2 ciper = [704796792, 752211 ...

  8. nyoj_19_擅长排列的小明_201403011600

    擅长排列的小明时间限制:1000 ms  |  内存限制:65535 KB 难度:4描述 小明十分聪明,而且十分擅长排列计算.比如给小明一个数字5,他能立刻给出1-5按字典序的全排列,如果你想为难他, ...

  9. MVC.Net:Razor指定模板

    在MVC.Net开发中,我们通常会在_ViewStart.cshtml中指定一个默认的模板,在文件开头输入如下代码: @{ Layout = "~/Views/Shared/[自己定义的模板 ...

  10. HDU 5435

    数位DP题,然而不会做.设dp[i][j]表示前i位异或和为j的时候的个数.先dp出所有的可能组合使得异或和为j的个数,然后按位进行枚举.对于dp[i][j],其实不止是前i位,对于后i位的情况同样适 ...