The Little Elephant loves numbers. 

He has a positive integer x. The Little Elephant wants to find the number of positive integers d, such that d is the divisor of x, and x and d have at least one common (the same) digit in their decimal representations. 

Help the Little Elephant to find the described number.

Input

A single line contains a single integer x (1 ≤ x ≤ 109).

Output

In a single line print an integer — the answer to the problem.

Examples

Input

1


Output

1


Input

10


Output

2
import java.io.*;
import java.util.*;

public class B {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int x = Integer.parseInt(in.readLine());
    int count = calc1(x);
    System.out.println(count);
    System.exit(0);
  }
  public static boolean sharesDigit (int a,int b){
    boolean shares = false;
    String as,bs;
    as = Integer.toString(a);
    bs = Integer.toString(b);
    for(int i=0;i<=9;i++){
      String is = Integer.toString(i);
      shares = shares || (as.contains(is) && bs.contains(is));
    }
    return shares;
  }
  public static int calc1(int x){
    int mdiv,count;
    mdiv = (int) Math.ceil(Math.sqrt(x));
    count = 0;
    for(int i=1;i<=mdiv;i++){
      if(x % i == 0 && i*i<=x){
        int div1 = i;
        int div2 = x/i;
        if(div1==div2){
          if(sharesDigit(x,div1)) count++;
        }
        else{
          if(sharesDigit(x,div1)) count++;
          if(sharesDigit(x,div2)) count++;
        }
      }
    }
    return count;
  }
  public static int calc2(int x){
    int count;
    count = 0;
    for(int i=1;i<=x;i++){
      if(x%i==0 && sharesDigit(x,i)) count++;
    }
    return count;
  }
}
