PUCMM025 - Divisor Digits

no tags 

Given a number, output how many digits of that number the number is itself divisible by. Count all occurrences 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
royhero: 2019-10-25 10:46:08

Easy one;)

cegprakash: 2019-05-17 03:47:18

Time limit well set for C++.

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...!!


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)