B. Inna and Nine

time limit per test

                                     1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Inna loves digit 9 very much. That's why she asked Dima to write a small number consisting of nines. But Dima must have misunderstood her and he wrote a very large number a, consisting of digits from 1 to 9.

Inna wants to slightly alter the number Dima wrote so that in the end the number contained as many digits nine as possible. In one move, Inna can choose two adjacent digits in a number which sum equals 9 and replace them by a single digit 9.

For instance, Inna can alter number 14545181 like this: 14545181 → 1945181 → 194519 → 19919. Also, she can use this method to transform number 14545181 into number 19991. Inna will not transform it into 149591 as she can get numbers 19919 and19991 which contain more digits nine.

Dima is a programmer so he wants to find out how many distinct numbers containing as many digits nine as possible Inna can get from the written number. Help him with this challenging task.

Input

The first line of the input contains integer a (1 ≤ a ≤ 10100000). Number a doesn't have any zeroes.

Output

In a single line print a single integer — the answer to the problem. It is guaranteed that the answer to the problem doesn't exceed 263 - 1.

Please, do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64dspecifier.

Examples

input

369727

output

2

input

123456789987654321

output

1

input

1

output

1

Note

Notes to the samples

In the first sample Inna can get the following numbers: 369727 → 99727 → 9997, 369727 → 99727 → 9979.

In the second sample, Inna can act like this: 123456789987654321 → 12396789987654321 → 1239678998769321.

 //2016.11.19
#include <iostream>
#include <cstdio> using namespace std;
const int N = 1e5+;
int num[N], sum[N]; int main()
{
string str;
while(cin >> str)
{
long long ans = ;
int n = str.length();
for(int i = ; i < n; i++)
{
num[i] = str[i]-'';
if(i==)sum[i] = ;
else sum[i] = num[i] + num[i-];
}
for(int i = ; i < n; i++)
{
int cnt = ;
while(sum[i] == )
{
cnt++;
i++;
}
if(cnt && cnt%==)ans*=(cnt/+);
}
cout<<ans<<endl;
}
return ;
}

Codeforces374B的更多相关文章

随机推荐

  1. sublime text 我的常用配置

    { "color_scheme": "Packages/Color Scheme - Default/IDLE.tmTheme", "font_fac ...

  2. SSL证书指令

    转自:http://blog.csdn.net/madding/article/details/26717963 生成Self Signed证书 # 生成一个key,你的私钥,openssl会提示你输 ...

  3. S3C2440串口及其中断系统详解

    个独立异步串行I/O(SIO)端口,每个都可以是基于中断或基于DMA模式的操作.换句话说,UART可以通过产生中断或DMA请求来进行CPU和UART之间的数据传输. 字节的FIFO给发送和接收. 字节 ...

  4. WCF中传递对象的成员变量行不通?

    今早通过WCF服务添加对象到数据库,有一个变量始终没有传过来 定义: public bool isLogin; 修改成 private bool _isLogin; public bool isLog ...

  5. 推荐一款非常好用的java反编译工具(转)

    源: 推荐一款非常好用的java反编译工具

  6. mybatis--常见的错误

    1.没有在configuration.xml配置对应的sql配置文件 错误: Error updating database. Cause: java.lang.IllegalArgumentExce ...

  7. Spring MVC之Action输入参数

    第一部分:Action输入参数Spring MVC 通过@RequestMapping注解映射请求,最终的真正执行代码为处理器方法,即@RequestMapping注解的方法.Spring MVC方法 ...

  8. android studio 更新失败解决办法

    在andriod studio目录下找到studio.exe.vmoptions这个文件,用记事本打开,在后面加上 -Djava.net.preferIPv4Stack=true -Didea.upd ...

  9. session cookie用法

    1.session(1)session存储在服务器的(2)session每个人存一份(3)session有默认的过期时间(4)session里面可以存储任意类型的数据安全,对服务造成压力用法:1.当一 ...

  10. WCF必须使用证书验证吗

    你说的 ASP.NET Web Service在消息头里加个字段,服务端做验证,这个是可以的,但是无法保证传输的用户名和密码是加密安全的. 要求使用证书,也是强制服务器端,这里涉及到服务器身份鉴别的问 ...