#include <bits/stdc++.h>
using namespace std;
int n, m, i, j, a, ans, l;
int fix[10000];
bool flag;
int main() {
  cin >> n;
  m = n;
  while (m > 0) {
    fix[m % 10] = 1;
    m /= 10;
  }
  for (i = 1; i * i <= n; i++)
    if (n % i == 0) {
      a = i;
      l = 0;
      flag = false;
      while (a > 0) {
        l++;
        if (fix[a % 10]) {
          flag = true;
          break;
        }
        a /= 10;
      }
      if (flag) ans++;
      if (i * i != n) {
        a = n / i;
        l = 0;
        flag = false;
        while (a > 0) {
          l++;
          if (fix[a % 10]) {
            flag = true;
            break;
          }
          a /= 10;
        }
        if (flag) ans++;
      }
    }
  cout << ans << endl;
}
