Problem description

There are n stones on the table in a row, each of them can be red, green or blue. Count the minimum number of stones to take from the table so that any two neighboring stones had different colors. Stones in a row are considered neighboring if there are no other stones between them.

Input

The first line contains integer n (1 ≤ n ≤ 50) — the number of stones on the table.

The next line contains string s, which represents the colors of the stones. We'll consider the stones in the row numbered from 1 to n from left to right. Then the i-th character s equals "R", if the i-th stone is red, "G", if it's green and "B", if it's blue.

Output

Print a single integer — the answer to the problem.

Examples

Input

3
RRG

Output

1

Input

5
RRRRR

Output

4

Input

4
BRBG

Output

0
解题思路:题目的意思就是输入的字符串中如果有相同的字符,去掉相同的字符,保留其中一个就好,保证序列中不出现相同的字符,问一共去掉多少个字符。简单处理字符串。
AC代码:
 #include<bits/stdc++.h>
using namespace std;
int main(){
int n,i=,sum=,num=;char str[];
cin>>n;getchar();//吃掉回车符对字符串的影响
cin>>str;
while(str[i]!='\0'){
if(str[i+]==str[i]){
while(str[i+]==str[i]){num++;i++;}
}
else {sum+=num;num=;i++;}
}
cout<<sum<<endl;
return ;
}

最新文章

  1. Ajax深入解析
  2. arcgis arcengine Using environment settings
  3. 【解决】若要使用报表生成器,必须在此计算机上安装 .Net Framework 3.5
  4. Altium Designer15 卡在登陆界面解决办法:
  5. AngularJS:如何使用自定义指令来取代ng-repeat
  6. 高性能JavaScript DOM编程
  7. 设置php下载文件的超时时间
  8. XPATH基础入门资料
  9. Java- 类型转换
  10. 采用sharedPreference保存数据
  11. Objective-C基调(4)Category
  12. Spring3+SpingMVC+Hibernate4全注解环境配置
  13. 多线程中使用CheckForIllegalCrossThreadCalls = false访问窗口
  14. f5电源模块损坏
  15. flask实现简单的接收json返回json的接口
  16. Spring Boot的快速创建
  17. java基础学习:JavaWeb之Cookie和Session
  18. r语言 技巧总结
  19. Spring Cloud 入门 之 Eureka 篇(一)
  20. mockito測試框架

热门文章

  1. java 异常报错总结
  2. [forward]警惕UNIX下的LD_PRELOAD环境变量
  3. Luogu P3901 数列找不同
  4. discourse论坛迁移
  5. gitblit 搭建本地git服务器
  6. python--(socket与粘包解决方案)
  7. 洛谷 2234 BZOJ 1588 HNOI2002 营业额统计
  8. PAT 1110 Complete Binary Tree
  9. 3.3.4 lambda 表达式
  10. 在全局对象(不是指针)的构造函数里不要对std集合做太多操作