#ifdef __APPLE__ #include "bits:stdc++.h" #else #include #endif using namespace std; typedef long long LL; typedef pair PLL; auto scan = []{ static LL a; scanf("%lld", &a); return a;}; const double PI = acos(-1); int main() { LL n = scan(), m = scan(); if (n <= 10) { LL ans = 1; for (LL i = 1; i <= n; ++i) ans *= i; while (ans % m == 0) ans /= m; double lgans = log10(ans); LL flo = (LL) lgans; lgans -= flo; printf("%.2fe%lld\n",pow(10,lgans),flo); } else { double lgans = log10(sqrt(2 * PI * n)) + n * log10(n/exp(1)), check = m; LL div = 0; //printf("%.4E\n",lgans); for (LL cur = m; cur <= n && check <= n + 1; cur = cur * m, check = check * m) div += n / cur; lgans -= log10(pow(m,div)); LL flo = (LL) lgans; lgans -= flo; printf("%.2fe%lld\n",pow(10,lgans),flo); } }