PUCMM025 - Divisor Digits

no tags 

Given a number, output how many digits in number that number itself is divisible by. Count all occurences of such digits in the number, not just the first.

For example, 12345 is divisible by 1, 3, and 5, so, the answer in this case must be 3.

Input

Each test case is a number between 1 and 10240.

Output

for each test case, output how many of its digits divide the number.

Example

Input:
12345
661232
312
730000000

Output:
3
3
3
0

hide comments
roy_24: 2016-07-27 08:17:22

Great insight, Arnab Mitra :p

minhthai: 2016-01-26 14:52:43

java users, u can use BigInteger :)

geoffreymace7: 2015-12-25 17:50:14

For those stuck on EOF, use while( scanf("%s",str) != EOF ){...},where str stores the number.

BadeMeow: 2015-10-26 07:09:10

Take care of leading zeros!!! Costed me WA's!

Harish Meena: 2015-10-23 13:13:55

stuck on eof

shravinson: 2015-09-03 11:11:10

7 is tricky

Shivam Singh: 2015-08-22 15:56:46

beware of divisibility by 7, 4 and 8
costed a lot of WAs

:.Mohib.:: 2015-07-15 15:49:45

Learn something....Nice One...!!

Rishabh Joshi: 2015-05-28 12:01:56

string data type will give TLE due to slower input output (as dynamic mem allocation is involved) suggested using char[] and scanf/printf.

Arnab Mitra: 2015-05-27 22:08:33

Easy if you can figure out a way to deal with divisibility with 7


Added by:Olson Ortiz
Date:2011-12-08
Time limit:0.207s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:C CSHARP C++ 4.3.2 CPP JAVA
Resource:Used in 2da Olimpiada de Programacion PUCMM-ACM-ISC (fase 2)