#include using namespace std; #include using namespace atcoder; using ll=long long; using Graph=vector>; #define MAX 2000000 #define MOD 1000000007 #define INF 1000000000 int main(){ int K; cin>>K; vector a={1,2,3,4,5,6,7,8}; int ans=0; int cnt=0; do{ cnt++; int x=0; int res=1; for(int i=7;i>=0;i--){ x+=a[i]*res; res*=10; } if(x%K==0){ ans++; } }while(next_permutation(a.begin(),a.end())); //cout<