#include #include using namespace std; using namespace atcoder; using ll = long long; #define rep(i,n) for(int i=0; i> K; string S = "12345678"; int ans = 0; do{ int x = stoi(S); if(x % K == 0) ans++; }while(next_permutation(S.begin(), S.end())); cout << ans << endl; return 0; }