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
2013-09-23 07:13:41 rajul
extra test cases pls...
2013-08-30 19:15:55 flop_coder
use divisibility rules.....got ac :D
2013-08-07 20:09:50 @DubeY@
completed half century !!!
easy one but do carefully!!
2013-07-31 17:26:14 P_Quantum
easy one..!!
2013-07-21 19:34:30 ***
nice one!!!
2013-07-04 12:25:56 Vijay Jain
after solving this try this one http://www.spoj.com/problems/NITT2/
2013-05-30 02:43:12 Chandan Mittal
The divisibility by 7 costed me 5WA
but finally got AC :)

Last edit: 2013-05-31 03:16:21
2013-03-26 17:51:36 Akb
easy one but do it carefully...!!
2013-03-12 18:05:35 Vipul Pandey
Nice one!
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.