PUCMM025 - Divisor Digits

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

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)

hide comments
2019-10-25 10:46:08
Easy one;)
2019-05-17 03:47:18 cegprakash
Time limit well set for C++.
2016-07-27 08:17:22
Great insight, Arnab Mitra :p
2016-01-26 14:52:43 minhthai
java users, u can use BigInteger :)
2015-12-25 17:50:14
For those stuck on EOF, use while( scanf("%s",str) != EOF ){...},where str stores the number.
2015-10-26 07:09:10 BadeMeow
Take care of leading zeros!!! Costed me WA's!
2015-10-23 13:13:55 Harish Meena
stuck on eof
2015-09-03 11:11:10 shravinson
7 is tricky
2015-08-22 15:56:46 Shivam Singh
beware of divisibility by 7, 4 and 8
costed a lot of WAs
2015-07-15 15:49:45 :.Mohib.:
Learn something....Nice One...!!
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.