/* ___ _ _ ___ __ ___ _ _ __ ____ ___ _ _ _ |__ /_\ |\ | | | | |__ |__| |_| |__ | |__| /_\ ___| / \ | \| | |__| ___| | | |__| |___ | | | / \ */ #include using namespace std; typedef long long ll; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); string s = "12345678"; ll ans = 0, n; cin >> n; if (stoi(s) % n == 0) ans++; while (next_permutation(s.begin(), s.end())) if (stoi(s) % n == 0) ans++; cout << ans << endl; return 0; }