#include <bits/stdc++.h>   using namespace std;   int A[10], B[10];   bool Check(int j) {     memset(B, 0, sizeof(B));     while (j) {       B[j % 10]++;       j /= 10;     }     for (int i = 0; i <= 9; i++)       if (A[i] && B[i]) return true;     return false;   }   int main() {     int res = 0, x, _x;     cin >> x;     _x = x;     while (_x) {       A[_x % 10]++;       _x /= 10;     }     double s = sqrt(x);     for (int i = 1; i <= s; i++) {       if (x % i == 0) {         if (Check(i)) res++;         if (i * i != x && Check(x / i)) res++;       }     }     cout << res << endl;   }   