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.PrintWriter;
import java.util.ArrayList;
import java.util.Scanner;

public class nB {

    Scanner in;
    PrintWriter out;

    boolean check(boolean ch[], int a) {
        while (a > 0) {
            if (ch[a % 10]) {
                return true;
            }
            a /= 10;
        }
        return false;
    }

    void solve() {
        int x = in.nextInt();
        if (x == 1) {
            out.println(1);
            return;
        }
        boolean ch[] = new boolean[10];
        int xx = x;
        while (xx > 0) {
            ch[xx % 10] = true;
            xx /= 10;
        }
        int kol = 0;
        for (int i = 1; i <= x / 50; i++) {
            if (x % i == 0 && check(ch, i)) {
                kol++;
            }
        }
        if (check(ch, x / 49) && x % 49 == 0) {
            kol++;
        }
        if (check(ch, x / 48) && x % 48 == 0) {
            kol++;
        }
        if (check(ch, x / 47) && x % 47 == 0) {
            kol++;
        }
        if (check(ch, x / 46) && x % 46 == 0) {
            kol++;
        }
        if (check(ch, x / 45) && x % 45 == 0) {
            kol++;
        }
        if (check(ch, x / 44) && x % 44 == 0) {
            kol++;
        }
        if (check(ch, x / 43) && x % 43 == 0) {
            kol++;
        }
        if (check(ch, x / 42) && x % 42 == 0) {
            kol++;
        }
        if (check(ch, x / 41) && x % 41 == 0) {
            kol++;
        }
        if (check(ch, x / 40) && x % 40 == 0) {
            kol++;
        }
        if (check(ch, x / 39) && x % 39 == 0) {
            kol++;
        }
        if (check(ch, x / 38) && x % 38 == 0) {
            kol++;
        }
        if (check(ch, x / 37) && x % 37 == 0) {
            kol++;
        }
        if (check(ch, x / 36) && x % 36 == 0) {
            kol++;
        }
        if (check(ch, x / 35) && x % 35 == 0) {
            kol++;
        }
        if (check(ch, x / 34) && x % 34 == 0) {
            kol++;
        }
        if (check(ch, x / 33) && x % 33 == 0) {
            kol++;
        }
        if (check(ch, x / 32) && x % 32 == 0) {
            kol++;
        }
        if (check(ch, x / 31) && x % 31 == 0) {
            kol++;
        }
        if (check(ch, x / 30) && x % 30 == 0) {
            kol++;
        }
        if (check(ch, x / 29) && x % 29 == 0) {
            kol++;
        }
        if (check(ch, x / 28) && x % 28 == 0) {
            kol++;
        }
        if (check(ch, x / 27) && x % 27 == 0) {
            kol++;
        }
        if (check(ch, x / 26) && x % 26 == 0) {
            kol++;
        }
        if (check(ch, x / 25) && x % 25 == 0) {
            kol++;
        }
        if (check(ch, x / 24) && x % 24 == 0) {
            kol++;
        }
        if (check(ch, x / 23) && x % 23 == 0) {
            kol++;
        }
        if (check(ch, x / 22) && x % 22 == 0) {
            kol++;
        }
        if (check(ch, x / 21) && x % 21 == 0) {
            kol++;
        }
        if (check(ch, x / 20) && x % 20 == 0) {
            kol++;
        }
        if (check(ch, x / 19) && x % 19 == 0) {
            kol++;
        }
        if (check(ch, x / 18) && x % 18 == 0) {
            kol++;
        }
        if (check(ch, x / 17) && x % 17 == 0) {
            kol++;
        }
        if (check(ch, x / 16) && x % 16 == 0) {
            kol++;
        }
        if (check(ch, x / 15) && x % 15 == 0) {
            kol++;
        }
        if (check(ch, x / 14) && x % 14 == 0) {
            kol++;
        }
        if (check(ch, x / 13) && x % 13 == 0) {
            kol++;
        }
        if (check(ch, x / 12) && x % 12 == 0) {
            kol++;
        }
        if (check(ch, x / 11) && x % 11 == 0) {
            kol++;
        }
        if (check(ch, x / 10) && x % 10 == 0) {
            kol++;
        }
        if (check(ch, x / 9) && x % 9 == 0) {
            kol++;
        }
        if (check(ch, x / 8) && x % 8 == 0) {
            kol++;
        }
        if (check(ch, x / 7) && x % 7 == 0) {
            kol++;
        }
        if (check(ch, x / 6) && x % 6 == 0) {
            kol++;
        }
        if (check(ch, x / 5) && x % 5 == 0) {
            kol++;
        }
        if (check(ch, x / 4) && x % 4 == 0) {
            kol++;
        }
        if (check(ch, x / 3) && x % 3 == 0) {
            kol++;
        }
        if (check(ch, x / 2) && x % 2 == 0) {
            kol++;
        }
        out.println(kol + 1);
    }

    void run() {
        in = new Scanner(System.in);
        out = new PrintWriter(System.out);
        try {
            solve();
        } finally {
            out.close();
        }
    }

    public static void main(String[] args) {
        new nB().run();
    }

}
