func_code_string: #include <bits/stdc++.h>   using namespace std;   template <typename T>   void read(T &a) {     register int b = 1, c = getchar();     a = 0;     for (; !isdigit(c); c = getchar())       if (c == 45) b *= -1;     for (; isdigit(c); c = getchar()) a = (a << 3) + (a << 1) + c - 48;     a *= b;   }   const int maxn = 105;   const int maxm = 1 << 18;   long long dp[maxm][maxn];   string str;   int len;   int m;   int main() {     cin >> str;     len = int((str).size());     read(m);     dp[0][0] = 1;     for (int msk = 0; msk < int(1 << len); msk++) {       for (int rem = 0; rem < int(m); rem++) {         for (int j = 0; j < int(len); j++)           if (!(msk & (1 << j))) {             int nwrem = (rem * 10 + str[j] -  0 ) % m;             int nwmsk = msk | (1 << j);             if (!msk && str[j] ==  0 ) continue;             dp[nwmsk][nwrem] += dp[msk][rem];           }       }     }     long long ans = dp[(1 << len) - 1][0];     for (int i = 0; i < int(10); i++) {       int cnt = 0;       for (int j = 0; j < int(len); j++) {         if (str[j] == i + 48) cnt++;       }       long long fac = 1;       for (int j = 1; j <= cnt; j++) fac *= j;       ans /= fac;     }     printf( %I64d n , ans);     return 0;   }   