#include <bits/stdc++.h>
using namespace std;
char num[15], divisor[15];
int main() {
  scanf("%s", num);
  int n = 0;
  int len = strlen(num);
  for (int i = 0; i < len; ++i) {
    n *= 10;
    n += num[i] - '0';
  }
  int cont = 0;
  bool valid = false;
  for (int i = 1; i * i <= n; ++i) {
    if (n % i == 0) {
      sprintf(divisor, "%d", i);
      valid = false;
      int l1 = strlen(divisor);
      for (int j = 0; j < l1 && !valid; ++j) {
        for (int k = 0; k < len; ++k) {
          if (divisor[j] == num[k]) {
            valid = true;
            cont++;
            break;
          }
        }
      }
      if (i != n / i) {
        sprintf(divisor, "%d", n / i);
        valid = false;
        int l1 = strlen(divisor);
        for (int j = 0; j < l1 && !valid; ++j) {
          for (int k = 0; k < len; ++k) {
            if (divisor[j] == num[k]) {
              valid = true;
              cont++;
              break;
            }
          }
        }
      }
    }
  }
  printf("%d\n", cont);
  return 0;
}
