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.BufferedReader;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author gnosis
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskB {
  boolean[] digits;
	public void solve(int testNumber, InputReader in, PrintWriter out) {
    int x = in.nextInt();
    digits = new boolean[20];
    int t = x;
    while(t  != 0) {
      digits[t % 10] = true;
      t /= 10;
    }

    int sq = (int) Math.sqrt((double)x);
    int answer = 0;
    for(int i = 1; i <= sq; ++i) {
      if(x % i == 0 )  {
        if(compare(i, x))answer++;
        if(i != x/i && compare(x/i, x))answer++;
      }
    }
    if(x == 1)answer = 1;
    out.println(answer);
	}

  private boolean compare(int num, int x) {
    boolean ok = false;
    while(num  != 0) {
      if( digits[num % 10] )return true;
      num /= 10;
    }
    return ok;
  }
}

class InputReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;

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

  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new StringTokenizer(reader.readLine());
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

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

}

