import java.math.BigDecimal; import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { new Main().run(); } void run() { Scanner sc = new Scanner(System.in); double n = sc.nextDouble(); double m = sc.nextDouble(); if (n < 100) { double ret = 1; for (int i = 2; i <= n; ++i) { int mul = i; while (mul % m == 0) mul /= m; ret *= mul; } int cnt = 0; while (ret >= 10) { ++cnt; ret /= 10; } System.out.println(ret + "e" + cnt); return; } long c = 0; for (int i = 1; i < 1000; ++i) c += n / Math.pow(m, i); ++n; long d = (long) (n * Math.log10((n + 1 / (12 * n - 1 / (10 * n))) / Math.E) + (Math.log10(2 * Math.PI) - Math.log10(n)) * 0.5 - c * Math.log10(m)); double p = fac(n); for (int i = 0; i < c; ++i) { p /= m; p = regulate(p); } System.out.println(p + "e" + d); } double fac(double n) { if (n < 1e8) { double ret = 1; for (int i = 1; i <= n; ++i) { ret *= i; ret = regulate(ret); } return ret; } double ret = Math.sqrt(2 * Math.PI) * pow(n / Math.E, (long) n) / Math.sqrt(n) * (1 + 1 / (12 * n) + 1 / (288 * n * n) - 139 / (51840 * n * n * n)); ret = regulate(ret); return ret; } double regulate(double a) { while (a >= 10) a /= 10; while (a < 1) a *= 10; return a; } double pow(double a, long n) { double ret = 1; for (; n > 0; n >>= 1, a *= a) { while (a >= 10) a /= 10; if (n % 2 == 1) { ret *= a; while (ret >= 10) ret /= 10; } } return ret; } void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }