Find the count of number of Digits in N that divides N

Given a number N, Find the digits in this number that exactly divide N and display their count. 


For Example:

If N = 24, there are 2 digits - 2 & 4. Both these digits exactly divide 24. So our answer is 2.

Duplicate numbers should also be counted, e.g., For N=122, 2 divides 122 exactly and occurs at ones' and tens' position. So it should be counted twice. So,  answer is 3.



Implementation:

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
int main() 
{
      int T;
      int M,N,count,rem;
      scanf("%d",&T);
      while(T>0)
      {
           scanf("%d",&N);
           M=N;
           count=0;
           while(N>0)
           {
                rem=N%10;
                if(rem!=0)
                if(M%rem==0)
                count++;
                N=N/10;
           }
           printf("%d\n",count);
           T--;
      }
return 0;
}

Sample Input

2
12
1012


Sample Output 


2
3

Input

The first line - T, number of test cases

Followed by T lines - an integer N

Output


Display the count of digits in N that exactly divide N.