Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

Description

Polycarpus has postcards and photos hung in a row on the wall. He decided to put them away to the closet and hang on the wall a famous painter's picture. Polycarpus does it like that: he goes from the left to the right and removes the objects consecutively. As Polycarpus doesn't want any mix-ups to happen, he will not carry in his hands objects of two different types. In other words, Polycarpus can't carry both postcards and photos simultaneously. Sometimes he goes to the closet and puts the objects there, thus leaving his hands free. Polycarpus must put all the postcards and photos to the closet. He cannot skip objects. What minimum number of times he should visit the closet if he cannot carry more than 5 items?

Input

The only line of the input data contains a non-empty string consisting of letters "С" and "P" whose length does not exceed 100 characters. If the i-th character in the string is the letter "С", that means that the i-th object (the numbering goes from the left to the right) on Polycarpus' wall is a postcard. And if the i-th character is the letter "P", than the i-th object on the wall is a photo.

Output

Print the only number — the minimum number of times Polycarpus has to visit the closet.

Sample Input

Input
CPCPCPC
Output
7
Input
CCCCCCPPPPPP
Output
4
Input
CCCCCCPPCPPPPPPPPPP
Output
6
Input
CCCCCCCCCC
Output
2

Hint

In the first sample Polycarpus needs to take one item to the closet 7 times.

In the second sample Polycarpus can first take 3 postcards to the closet; then 3 more. He can take the 6 photos that are left in the similar way, going to the closet twice.

In the third sample Polycarpus can visit the closet twice, both times carrying 3 postcards. Then he can take there 2 photos at once, then one postcard and finally, he can carry the last 10 photos if he visits the closet twice.

In the fourth sample Polycarpus can visit the closet twice and take there all 10 postcards (5 items during each go).

 #include<stdio.h>
#include<string.h> int main()
{
char CP[];
int num = ,allnum = ,i;
scanf("%s",CP);
for(i = ;i < strlen(CP);i++)//被提醒strlen什么的不要放在里面会加大时间复杂度
{
if(num <= && CP[i] == CP[i+])
num++;
if(num == || CP[i] != CP[i+])
{
allnum++;
num = ;
}
}
printf("%d",allnum);
return ;
}
 

最新文章

  1. Java--Stream,NIO ByteBuffer,NIO MappedByteBuffer性能对比
  2. 操作系统开发系列—1.HelloWorld ●
  3. Eclipse debug高级技巧(转)
  4. hdu 2108:Shape of HDU(计算几何,判断多边形是否是凸多边形,水题)
  5. 利用Roslyn把C#代码编译到内存中并进行执行
  6. 【ZZ】常用推荐算法
  7. jquery mobile图片自适应屏幕
  8. PHP要注意的14个问题
  9. 【sql进阶】SQL Server 将某一列的值拼接成字符串
  10. 解决CSS中float:left后需要clear:both清空的繁琐步骤(转)
  11. ImageMagick 拼图及切图方法
  12. iOS 之 线性布局
  13. spring中的自定义标签
  14. Salesforce的对象和字段
  15. Linux中设置服务自启动的三种方式,ln -s 建立启动软连接
  16. AngularJS 1.x系列:AngularJS过滤器(4)
  17. DotNetty 实现 Modbus TCP 系列 (二) ModbusFunction 类图及继承举例
  18. excel中如何隐藏列和取消隐藏列
  19. 20170803 Airflow自带的API进行GET 和POST动作部分内容
  20. 【GAN与NLP】GAN的原理 —— 与VAE对比及JS散度出发

热门文章

  1. CTF 常见操作总结
  2. 第十章、sys模块
  3. /etc/ld.so.conf.d/目录下文件的作用
  4. 修改虚拟机CentOS系统ip地址和主机名
  5. Asp.Net Zero通用打印实现
  6. android如何自动切换后台app
  7. JNetPcap安装及使用
  8. Windows 端口占用查询
  9. zencart批量评论插件Easy Populate CSV add reviews使用教程
  10. netty-2.客户端与服务端互发消息