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. Andriod学习笔记 - 参考

    Andriod学习笔记 - 参考 自定义实现圆形播放进度条(android,飞一般的感觉) 盘点Android开发者必备的十大开发工具

  2. 小P的强力值

    小P的强力值 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 小Hi在虚拟世界中有一只小宠物小P.小P有K种属性,每种属性的初始值为Ai.小Ho送给了小Hi若干颗药丸,每 ...

  3. ExtJS如何取得GridPanel当前选择行数据对象 - nuccch的专栏 - 博客频道 - CSDN.NET

    body { font-family: "Microsoft YaHei UI","Microsoft YaHei",SimSun,"Segoe UI ...

  4. (中等) Hiho 1232 Couple Trees(15年北京网络赛F题),主席树+树链剖分。

    "Couple Trees" are two trees, a husband tree and a wife tree. They are named because they ...

  5. Cocos2dx 学习笔记整理----在项目中使用图片(三)

    这节练习下DragonBones. 手机由于性能所限,需要特注意资源的使用. 游戏项目的话由于资源比较多,一般都会用到DragonBones来做动作,这个又称为龙骨. DragonBones传送点:h ...

  6. Linux/hp unix/AIX日常巡检脚本(转)

    以下为Linux/hp unix/AIX日常巡检脚本,大家可以参考着进行改写,用于自己的服务器. #!/usr/bin/ksh syserrdate=`date +"%m/%d"` ...

  7. Bestcoder #80

    首先吐槽一下,ca爷出的这套题到处都是坑,bestcoder变成besthack,Ranting已经掉得不能看了 A题: 链接:http://acm.hdu.edu.cn/showproblem.ph ...

  8. iOS开发——九切片

    这个虽然就我来说,感觉它没啥用,但还是放这吧,有时间了把内容补上.

  9. laravel安装excel功能

    原文安装链接:https://github.com/Maatwebsite/Laravel-Excel 代码如下: if ($rows = DB::connection('glist')->ta ...

  10. C#中Console.WriteLine()函数输出格式详解

    格式项都采用如下形式: {index[,alignment][:formatString]} 其中"index"指索引占位符,这个肯定都知道: ",alignment&q ...