#include <bits/stdc++.h>
using namespace std;
int main() {
  int x;
  int dig[10] = {0};
  int temp, i, j;
  cin >> x;
  temp = x;
  while (x > 0) {
    dig[x % 10]++;
    x /= 10;
  }
  x = temp;
  if (x == 1) {
    printf("1\n");
    return 0;
  }
  int ret = 1;
  if (dig[1] > 0) ret++;
  for (i = 2; i * i <= x; i++) {
    if (x % i == 0) {
      j = x / i;
      temp = i;
      while (temp > 0) {
        if (dig[temp % 10] > 0) {
          ret++;
          break;
        }
        temp /= 10;
      }
      temp = j;
      while (temp > 0) {
        if (dig[temp % 10] > 0) {
          ret++;
          if (i == j) ret--;
          break;
        }
        temp /= 10;
      }
    }
  }
  cout << ret << endl;
  return 0;
}
