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.util.Scanner;

/**
 *
 * @author Nur Endah Safitri
 */
public class B221 {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int count = 0;
        String aa = "" + a;
        int[] digit = new int[10];
        for (int i = 0; i < aa.length(); i++) {
            digit[Integer.parseInt(aa.charAt(i) + "")] = 1;
        }
        for (int i = 1; i < (int) Math.ceil(Math.sqrt((double) a)); i++) {
            if (a % i == 0) {
                String temp = "" + i + "";
                boolean add1 = false, add2 = false;
                for (int j = 0; j < temp.length(); j++) {
                    if (digit[Integer.parseInt(temp.charAt(j) + "")] == 1 && add1 == false) {
                        count++;
                        add1 = true;
                    }
                }
                int o = a / i;
                temp = "" + o + "";
                for (int j = 0; j < temp.length(); j++) {
                    boolean add = false;
                    if (digit[Integer.parseInt(temp.charAt(j) + "")] == 1 && add2 == false) {
                        add2 = true;
                        count++;
                    }
                }
            }
        }
        if (a % Math.ceil(Math.sqrt((double) a)) == 0) {
            String temp = "" + (int) Math.ceil(Math.sqrt((double) a));
            boolean add = false;
            for (int j = 0; j < temp.length(); j++) {
                if (digit[Integer.parseInt(temp.charAt(j) + "")] == 1 && add == false) {
                    count++;
                    add = true;
                }
            }
        }
        if (a == 1 || a == 2) {
            count = 1;
        }
        System.out.println(count);
    }
}
