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. Gson通过借助TypeToken获取泛型参数的类型的方法

    最近在使用Google的Gson包进行Json和Java对象之间的转化,对于包含泛型的类的序列化和反序列化Gson也提供了很好的支持,感觉有点意思,就花时间研究了一下. 由于Java泛型的实现机制,使 ...

  2. Android apk反编译基础(apktoos)图文教程

    本文主要介绍了Android apk反编译基础,使用的工具是apktoos,我们将用图文的方式说明apktoos工具的使用方式,你可以参考这个方法反编译其它APK试试看了 很久有写过一个广工图书馆主页 ...

  3. jQuery中的attr()和prop()使用

    总结:除了checked.seleted这样的属性推荐用prop()外,其他的随意都可以. 原因如下: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML ...

  4. ZOJ 3940 Modulo Query

    0--M对某个数字取模,相当于把0--M区间进行切割,每次暴力切割一下.结果的算的时候二分一下即可... 看了官方题解才会... #include<cstdio> #include< ...

  5. zookeoper在root下设置开机启动

    1 准备工作 1) 切换到/etc/rc.d/init.d/目录下 2) 创建zookeeper文件:touch zookeeper 3)更新权限:chmod +777 zookeeper 4)编辑文 ...

  6. TCP协议和UDP协议的区别

    1. TCP协议面向连接. UDP协议面向非连接 (有无链接)2. TCP协议传输速度慢. UDP协议传输速度快 (传输速度)3. TCP协议保证数据顺序. UDP协议不保证 (数据的有序性. 在IP ...

  7. Delphi 数据类型的说明

    简单类型包括实数类型(Real) 和有序类型(Ordinal),有序类型又包括整数类型,字符类型,布尔类型,枚举类型和子界类型等. 数据类型                       范围      ...

  8. Lambda表达式例子

    转 Lambda表达式例子 1.Java8 新特性介绍 写java的同学对java8肯定知道 那么java8到底有哪些特性呢,总结如下: Lambda表达式 函数式接口 Stream Optional ...

  9. ajax 基础2

    连接数据库实现分页功能 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Defa ...

  10. window下Git和github入门

    tip:使用简单的例子来制作一个使用指南过程,默认文件夹为demo.看了3个早晨,写一下留个记录,可能有些不成熟,如有错误欢迎指正. 参考一:http://www.liaoxuefeng.com/wi ...