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.math.BigInteger;
import java.util.*;

/**
 *
 * @author Saju
 *
 */
public class Main {

    static int[] dx = {0, 1, 0, -1};
    static int[] dy = {-1, 0, 1, 0};

    public static void main(String[] args) {

        InputReader in = new InputReader(System.in);

        int n = in.nextInt();
        List<Integer> list = getDivisior(n);
        int count = 0;
        for (Integer e : list) {
//                   System.out.println(e);
            String s = String.valueOf(e);
            String s1 = String.valueOf(n);

            for (int i = 0; i < s.length(); i++) {
                if (s1.contains(String.valueOf(s.charAt(i)))) {
                    count++;
                    break;
                }
            }

        }
        System.out.println(count);
        System.exit(0);

    }

    private static List<Integer> getDivisior(int n) {
        List<Integer> list = new ArrayList<>();

        for (int i = 1; i <= Math.sqrt(n); i++) {
            if (n % i == 0) {
                int a = i;
                int b = n / i;
                if (a != b) {
                    list.add(a);
                    list.add(b);
                } else {
                    list.add(a);
                }
            }
        }

        return list;
    }

    private static double getDistance(double x1, double y1, double x2, double y2) {

        return Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2);
    }

    private static int getDecimal(String str) {
        int val = 0;

        for (int i = str.length() - 1, j = 0; i >= 0; i--, j++) {
            if (str.charAt(i) == '1') {
                val += Math.pow(2, j);
            }
        }
        return val;
    }

    private static int call(int i, int j, int[][] colors) {

        if (i >= colors.length) {
            return 0;
        }

        if (dp[i][j] != -1) {
            return dp[i][j];

        }

        int result = Integer.MAX_VALUE;

        for (int k = 0; k < 3; k++) {
            if (k == j) {
                continue;
            } else {
                result = Math.min(result, call(i + 1, k, colors) + colors[i][j]);
            }
        }

        return dp[i][j] = result;
    }

    static int dp[][];

    private static class Graph {

        List<Edge> adjList[];
        int v;
        boolean visited[];
        int first[];
        int second[];

        Graph(int n) {
            this.v = n;
            adjList = new ArrayList[n];
            visited = new boolean[n];
            first = new int[n];
            second = new int[n];

            for (int i = 0; i < n; i++) {
                adjList[i] = new ArrayList<>();
            }
        }

        public void addEdge(int u, int v, int w) {
            adjList[u].add(new Edge(u, v, w));
            adjList[v].add(new Edge(v, u, w));
        }

        private void bfsAnother(int source) {
            Arrays.fill(visited, false);
            visited[source] = true;
            Queue<Integer> queue = new LinkedList<>();
            queue.add(source);
            second[source] = 0;

            while (!queue.isEmpty()) {
                int u = queue.remove();

                for (Edge e : adjList[u]) {
                    if (!visited[e.v]) {
                        queue.add(e.v);
                        visited[e.v] = true;
                        second[e.v] = second[u] + e.w;
                    }
                }
            }
        }

        int firstFarthest;

        private void bfs(int source) {
            Arrays.fill(visited, false);
            visited[source] = true;
            Queue<Integer> queue = new LinkedList<>();
            queue.add(source);
            int max = 0;
            first[source] = 0;

            while (!queue.isEmpty()) {
                int u = queue.remove();
                if (first[u] > max) {
                    max = first[u];
                    firstFarthest = u;
                }
                for (Edge e : adjList[u]) {
                    if (!visited[e.v]) {
                        queue.add(e.v);
                        visited[e.v] = true;
                        first[e.v] = first[u] + e.w;
                    }
                }
            }
        }

        public int dfs(int source) {

            visited[source] = true;
            int val = 0;
            int max = 0;
            for (Edge e : adjList[source]) {
                val = 0;
                if (!visited[e.v]) {
                    val += (e.w + dfs(e.v));
                }
                max = Math.max(val, max);
            }

            return max;
        }
    }

    private static class Edge {

        int u;
        int v;
        int w;

        Edge(int u, int v, int w) {
            this.u = u;
            this.v = v;
            this.w = w;
        }
    }

    private static BigInteger fac(int n, int mod) {

        if (n <= 0) {
            return BigInteger.ONE;
        }
        return BigInteger.valueOf(n).multiply(fac(n - 1, mod));
    }

    private static long bigMod(long n, long k, long m) {

        long ans = 1;
        while (k > 0) {
            if ((k & 1) == 1) {
                ans = (ans * n) % m;
            }
            n = (n * n) % m;
            k >>= 1;
        }
        return ans;
    }

    private static int upperBound(long[] arr, long num) {

        int start = 0;
        int end = arr.length;

        int mid = 0;
        int index = 0;
        while (true) {

            if (start > end) {
                break;
            }
            mid = (start + end) / 2;
            if (arr[mid] > num) {
                end = mid - 1;

            } else if (arr[mid] < num) {
                start = mid + 1;
            } else {
                return mid;
            }

        }

        // System.out.println(mid);
        if (arr[mid] < num) {
            index = mid + 1;
        } else {
            index = mid;
        }
        return index;
    }

    static class InputReader {

        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            tokenizer = null;
        }

        public String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());

                }
            } catch (IOException e) {
                return null;
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            String line = null;
            try {
                tokenizer = null;
                line = reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return line;
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public boolean hasNext() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (Exception e) {
                return false;
            }
            return true;
        }
    }
}

 		 			      	 	 	 	  	  	  	