#include <bits/stdc++.h>
using namespace std;
int main() {
  int x;
  scanf("%d", &x);
  int temp = x;
  bool digits[10];
  memset(digits, false, sizeof(digits));
  while (temp) {
    digits[temp % 10] = true;
    temp /= 10;
  }
  int count = 0;
  int square = (int)floor(sqrt(x));
  for (int i = 1; i <= square; i++) {
    if (x % i == 0) {
      int temp = i;
      while (temp) {
        if (digits[temp % 10]) {
          count++;
          break;
        }
        temp /= 10;
      }
      temp = x / i;
      if (temp == i) continue;
      while (temp) {
        if (digits[temp % 10]) {
          count++;
          break;
        }
        temp /= 10;
      }
    }
  }
  printf("%d\n", count);
  return 0;
}
