#include <bits/stdc++.h>
using namespace std;
bool isprime(long long int x) {
  if (x == 2)
    return true;
  else if (x % 2 == 0) {
    return false;
  } else {
    for (long long int i = 3; i <= sqrt(x); i++) {
      if (x % i == 0) return false;
    }
  }
  return true;
}
string convertInt(int number) {
  if (number == 0) return "0";
  string temp = "";
  string returnvalue = "";
  while (number > 0) {
    temp += number % 10 + 48;
    number /= 10;
  }
  for (int i = 0; i < temp.length(); i++)
    returnvalue += temp[temp.length() - i - 1];
  return returnvalue;
}
bool check(long long int x, long long int y) {
  string xs = convertInt(x);
  string ys = convertInt(y);
  for (long long int i = 0; i < xs.length(); i++) {
    for (long long int j = 0; j < ys.length(); j++) {
      if (xs.at(i) == ys.at(j)) return true;
    }
  }
  return false;
}
bool conatinone(long long int x) {
  string xs = convertInt(x);
  for (int i = 0; i < xs.length(); i++) {
    if (xs[i] == '1') return true;
  }
  return false;
}
int main() {
  vector<long long int> v;
  long long int x;
  cin >> x;
  if ((x == 1) || (isprime(x) == true && conatinone(x) == false)) {
    cout << 1 << endl;
    return 0;
  } else if ((isprime(x) == true && conatinone(x) == true)) {
    cout << 2 << endl;
    return 0;
  } else {
    long long int i;
    int c = 0;
    long long int y = sqrt(x);
    for (i = 1; i <= y; i++) {
      if (x % i == 0) {
        v.push_back(i);
        if (y != (x / i)) v.push_back(x / i);
      }
    }
    if (i * i == x) v.push_back(i);
    for (int i = 0; i < v.size(); i++) {
      if (check(x, v[i]) == true) c++;
    }
    cout << c << endl;
  }
  return 0;
}
