#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXN = 1000;
const int MAXVAL = 60;
const int C = MAXVAL + 1;
typedef double Mat[MAXVAL + 2][MAXVAL + 2];
int N;
double p;
int pp;
double E[MAXVAL + 1][MAXVAL + 3];
double F[MAXVAL + 1][MAXVAL + 2];
double pgeq[MAXVAL + 1][MAXVAL + 3];
double peq[MAXVAL + 1][MAXVAL + 2];
Mat A;
Mat B;
void mmult(Mat &A, Mat &B) {
  static Mat C;
  for (int i = (0); i <= (MAXVAL + 1); ++i)
    for (int j = (0); j <= (MAXVAL + 1); ++j) {
      double cur = 0;
      for (int k = (0); k <= (MAXVAL + 1); ++k) cur += A[i][k] * B[k][j];
      C[i][j] = cur;
    }
  for (int i = (0); i <= (MAXVAL + 1); ++i)
    for (int j = (0); j <= (MAXVAL + 1); ++j) A[i][j] = C[i][j];
}
void mpow(Mat &B, Mat &A, int n) {
  for (int i = (0); i <= (MAXVAL + 1); ++i)
    for (int j = (0); j <= (MAXVAL + 1); ++j) B[i][j] = i == j ? 1 : 0;
  while (n > 0) {
    if (n & 1) mmult(B, A);
    mmult(A, A);
    n /= 2;
  }
}
double EC[MAXVAL + 1][MAXVAL + 2];
double FC[MAXVAL][MAXVAL][MAXVAL + 2];
void addto(double *dst, double mlt, double *src, int shift) {
  for (int i = (shift); i <= (MAXVAL); ++i) dst[i] += mlt * src[i - shift];
  for (int i = (1); i <= (shift); ++i) assert(src[MAXVAL - shift + i] == 0);
  dst[C] += mlt * src[C];
}
void run() {
  scanf("%d%d", &N, &pp);
  p = 0.000000001 * pp;
  if (N == 1) {
    printf("%.9lf\n", p * 1 + (1 - p) * 2);
    return;
  }
  pgeq[1][1] = 1;
  pgeq[1][2] = 1 - p;
  pgeq[1][3] = 0;
  for (int n = (2); n <= (MAXVAL); ++n) {
    pgeq[n][1] = 1;
    pgeq[n][2] = (1 - p) + p * p;
    for (int x = (3); x <= (n + 2); ++x)
      pgeq[n][x] = pgeq[n][x - 1] * pgeq[n - 1][x - 1];
  }
  for (int n = (1); n <= (MAXVAL); ++n)
    for (int x = (1); x <= (n + 1); ++x)
      peq[n][x] = pgeq[n][x] - pgeq[n][x + 1];
  F[0][0] = F[0][1] = E[0][2] = 0;
  for (int n = (1); n <= (MAXVAL); ++n) {
    F[n][0] = 2 + E[n - 1][2];
    for (int x = (1); x <= (n + 1); ++x)
      F[n][x] = peq[n][x] / (1 - pgeq[n][x + 1]) * (x + F[n - 1][x - 1]) +
                (1 - pgeq[n][x]) / (1 - pgeq[n][x + 1]) * F[n][x - 1];
    assert(pgeq[n][n + 2] == 0);
    E[n][n + 2] = F[n][n + 1];
    for (int x = n + 1; x >= 2; --x)
      E[n][x] = pgeq[n][x] * (1 + E[n][x + 1]) + (1 - pgeq[n][x]) * F[n][x - 1];
  }
  for (int j = MAXVAL - 1; j >= 0; --j) {
    FC[j][0][C] += 2;
    FC[j][0][1] += 1;
    for (int x = (1); x <= (MAXVAL - 1 - j); ++x) {
      FC[j][x][C] += peq[x + 1][x] / (1 - pgeq[x + 1][x + 1]) * x;
      addto(FC[j][x], peq[x + 1][x] / (1 - pgeq[x + 1][x + 1]),
            FC[j + 1][x - 1], 1);
      addto(FC[j][x], (1 - pgeq[x][x]) / (1 - pgeq[x + 1][x + 1]), FC[j][x - 1],
            0);
    }
  }
  addto(EC[MAXVAL], 1, FC[0][MAXVAL - 1], 0);
  for (int x = MAXVAL - 1; x >= 2; --x) {
    EC[x][C] += pgeq[x][x];
    addto(EC[x], pgeq[x][x], EC[x + 1], 0);
    addto(EC[x], 1 - pgeq[x][x], FC[0][x - 1], 0);
  }
  for (int i = (0); i < (MAXVAL); ++i) A[i + 1][i] = 1;
  for (int i = (0); i < (MAXVAL); ++i) A[MAXVAL - i][MAXVAL] = EC[2][i + 1];
  A[C][MAXVAL] = EC[2][C];
  A[C][C] = 1;
  mpow(B, A, N - 2);
  double EN1 = B[C][1];
  for (int i = (0); i <= (MAXVAL); ++i) EN1 += B[i][1] * E[i][2];
  double EN2 = B[C][0];
  for (int i = (0); i <= (MAXVAL); ++i) EN2 += B[i][0] * E[i][2];
  double ret = (1 - p + p * p) * (2 + EN1) + p * (1 - p) * (3 + EN2);
  printf("%.9lf\n", ret);
}
int main() {
  run();
  return 0;
}
