Problem description

As you may know, MemSQL has American offices in both San Francisco and Seattle. Being a manager in the company, you travel a lot between the two cities, always by plane.

You prefer flying from Seattle to San Francisco than in the other direction, because it's warmer in San Francisco. You are so busy that you don't remember the number of flights you have made in either direction. However, for each of the last n days you know whether you were in San Francisco office or in Seattle office. You always fly at nights, so you never were at both offices on the same day. Given this information, determine if you flew more times from Seattle to San Francisco during the last n days, or not.

Input

The first line of input contains single integer n (2 ≤ n ≤ 100) — the number of days.

The second line contains a string of length n consisting of only capital 'S' and 'F' letters. If the i-th letter is 'S', then you were in Seattle office on that day. Otherwise you were in San Francisco. The days are given in chronological order, i.e. today is the last day in this sequence.

Output

Print "YES" if you flew more times from Seattle to San Francisco, and "NO" otherwise.

You can print each letter in any case (upper or lower).

Examples

Input

4
FSSF

Output

NO

Input

2
SF

Output

YES

Input

10
FFFFFFFFFF

Output

NO

Input

10
SSFFSFFSFF

Output

YES

Note

In the first example you were initially at San Francisco, then flew to Seattle, were there for two days and returned to San Francisco. You made one flight in each direction, so the answer is "NO".

In the second example you just flew from Seattle to San Francisco, so the answer is "YES".

In the third example you stayed the whole period in San Francisco, so the answer is "NO".

In the fourth example if you replace 'S' with ones, and 'F' with zeros, you'll get the first few digits of π in binary representation. Not very useful information though.

解题思路:题目的意思就是如果字符串中S->F字符变化次数大于F->S的变化次数,则为"YES",否则为"NO",简单处理字符串!

AC代码:

 #include<bits/stdc++.h>
typedef long long LL;
using namespace std;
int main(){
int n,i=,t1=,t2=;char s[];//t1表示S->F的变化次数,t2表示F->S的变化次数
cin>>n;getchar();//吃掉回车符对字符串的影响
cin>>s;
while(s[i]!='\0'){
if(s[i]=='S'){
while(s[i]=='S')i++;
if(s[i]!='\0')t1++;//不到末尾才可以加1,因为字符串中只有两个字符,既不是结束符,也跳出了上一步的循环,说明接下来的字符必为'F',则t1加1
}
else{
while(s[i]=='F')i++;
if(s[i]!='\0')t2++;//理由同上
}
}
if(t1>t2)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
return ;
}

最新文章

  1. ERP软件的价格设计
  2. 使用 zssh 进行 Zmodem 文件传输
  3. 如何低成本的打造HTC Vive虚拟演播室直播MR视频?
  4. MVC 与传统的 webform 的比较
  5. digitalocean
  6. VMware中Ubuntu忘记密码的解决办法
  7. lesson1:threadlocal的使用demo及源码分析
  8. QT插件开发方式(没看懂)
  9. ios数据存储——数据库:SQlite3以及第三方库FMDB
  10. noip2016天天爱跑步
  11. 我的Linux软件集
  12. HDU1171--01背包
  13. Tomcat关闭日志输出
  14. c# 制作正方形图片
  15. 结对编程项目——C语言实现WordCount Web化
  16. html 转义处理
  17. jQuery EasyUI 折叠面板accordion的使用实例
  18. Zabbix使用netstat监控会话
  19. ReactNative学习笔记(三)打包、调试、运行等相关介绍
  20. 洛谷 P1020 导弹拦截(dp+最长上升子序列变形)

热门文章

  1. @RequestMapping与controller方法返回值介绍
  2. switch方法中使用数字区间
  3. 新手入门学习angular.js的心得体会
  4. Linux判断
  5. GlobalSign 域名型 SSL 证书
  6. JavaSE 学习笔记之多线程(十三)
  7. hdu 3605 最大流sap+二进制思想(啊啊)
  8. 这书真的不错--Spring MVC Beginner&#39;s Guide
  9. Spring MVC-视图解析器(View Resolverr)-资源包视图解析器(Resource Bundle View Resolver)示例(转载实践)
  10. memcached集群