Problem description

Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.

Unfortunately, not all numbers are lucky. Petya calls a number nearly lucky if the number of lucky digits in it is a lucky number. He wonders whether number n is a nearly lucky number.

Input

The only line contains an integer n (1 ≤ n ≤ 1018).

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

Output

Print on the single line "YES" if n is a nearly lucky number. Otherwise, print "NO" (without the quotes).

Examples

Input

40047

Output

NO

Input

7747774

Output

YES

Input

1000000000000000000

Output

NO

Note

In the first sample there are 3 lucky digits (first one and last two), so the answer is "NO".

In the second sample there are 7 lucky digits, 7 is lucky number, so the answer is "YES".

In the third sample there are no lucky digits, so the answer is "NO".

解题思路:简单字符串处理。如果输入的字符串中出现'4'或'7'的次数总和num刚好为4次或7次,则输出"YES"。为什么只有4或7呢?因为规定的字符串长度最长为19,而幸运数字(只由4或7组成)有4,7,47...,第三个数47比最长长度值19还大,即num最大为19,所以只需看num是否为4或7,是则输出"YES",否则输出"NO"。

AC代码:

 #include<bits/stdc++.h>
using namespace std;
int main(){
char str[];int num=;
cin>>str;
for(int i=;str[i]!='\0';++i)
if(str[i]=='' || str[i]=='')num++;
if(num== || num==)cout<<"YES"<<endl;
else cout<<"NO"<<endl;
return ;
}

B - Nearly Lucky Number的更多相关文章

  1. 枚举 + 进制转换 --- hdu 4937 Lucky Number

    Lucky Number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)To ...

  2. SCU3502 The Almost Lucky Number

    Description A lucky number is a number whose decimal representation contains only the digits \(4\) a ...

  3. HDOJ 4937 Lucky Number

    当进制转换后所剩下的为数较少时(2位.3位),相应的base都比較大.能够用数学的方法计算出来. 预处理掉转换后位数为3位后,base就小于n的3次方了,能够暴力计算. . .. Lucky Numb ...

  4. 题目1380:lucky number

    转载请注明文本链接 http://blog.csdn.net/yangnanhai93/article/details/40441709 题目链接地址:http://ac.jobdu.com/prob ...

  5. HDU 3346 Lucky Number

    水题 #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> us ...

  6. 九度oj 题目1380:lucky number

    题目描述: 每个人有自己的lucky number,小A也一样.不过他的lucky number定义不一样.他认为一个序列中某些数出现的次数为n的话,都是他的lucky number.但是,现在这个序 ...

  7. 『NYIST』第九届河南省ACM竞赛队伍选拔赛[正式赛二]- Nearly Lucky Number(Codeforces Beta Round #84 (Div. 2 Only)A. Nearly)

    A. Nearly Lucky Number time limit per test 2 seconds memory limit per test 256 megabytes input stand ...

  8. ZOJ 3233 Lucky Number

    Lucky Number Time Limit: 5000ms Memory Limit: 32768KB This problem will be judged on ZJU. Original I ...

  9. lightoj 1097 - Lucky Number(线段树)

    Lucky numbers are defined by a variation of the well-known sieve of Eratosthenes. Beginning with the ...

随机推荐

  1. 时序分析:DTW算法(基于模板)

    对时序对象进行分析,使用KMP算法可以分析速率不变的模式,参考时序分析:欧式空间轨迹模式识别.使用基于模板匹配的方法,对于速率发生变化的模式,需要用新的对速率要求松散的方法,DTW方法为一种广泛使用的 ...

  2. 【sqli-labs】 less9 GET - Blind - Time based. - Single Quotes (基于时间的GET单引号盲注)

    加and http://localhost/sqli/Less-9/?id=1' and '1'='1%23 http://localhost/sqli/Less-9/?id=1' and '1'=' ...

  3. Arduino LM35温度检测

    一. 接线原理图 二.实物图 三.代码例子

  4. layui 下拉框取值

    layui.use('form', function () { var form = layui.form; form.on('select(Status)', function (data) { c ...

  5. python的自动化测试报告

    #coding=utf-8import HTMLTestRunnerimport BeautifulReportimport unittestclass MyTest(unittest.TestCas ...

  6. windows的时间同步工具:w32time

    windows 客户端 官方文档自己排查可以看一下 如何在 Windows Server 中配置权威时间服务器 Windows Time Service Technical Reference Win ...

  7. iphone 事件冒泡规则

    今天碰到的一个比较烦人的问题是,在body上添加事件处理函数,发现在iphone上怎么也没办法触发事件,找了半天,发现iPhone处理冒泡事件的规则: 1.点击某个元素: 2.如果这个元素上没有处理该 ...

  8. 1.VMware虚拟机的安装

    1.找到安装软件 2.使用如下操作安装 3.选择接受协议 4.修改安装目录 5.如果上一步有修改,此步骤不用改路径 7.安装后创建桌面快捷方式 8.安装成功可以看到桌面上有快捷方式图标 安装结束 声明 ...

  9. 1.sts的下载安装

    sts的官方下载如下: http://spring.io/tools3/sts/all/ 将下载后的压缩文件解压,在解压后的sts-bundle下的sts-3.9.1RELEASE目录中STS.exe ...

  10. NLP问题特征表达基础 - 语言模型(Language Model)发展演化历程讨论

    1. NLP问题简介 0x1:NLP问题都包括哪些内涵 人们对真实世界的感知被成为感知世界,而人们用语言表达出自己的感知视为文本数据.那么反过来,NLP,或者更精确地表达为文本挖掘,则是从文本数据出发 ...