#include <bits/stdc++.h>
using namespace std;
const int N = 60, m = 50;
double p, a[N][N], b[N][N], f[N][N], v[N][N];
int n;
struct matrix {
  double w[N][N];
  void operator*=(const matrix &c) {
    for (int i = 0; i <= m; ++i)
      for (int j = 0; j <= m; ++j) v[i][j] = w[i][j], w[i][j] = 0;
    for (int i = 0; i <= m; ++i)
      for (int j = 0; j <= m; ++j)
        for (int k = 0; k <= m; ++k) w[i][k] += v[i][j] * c.w[j][k];
    return;
  }
} Ans, trans, tmp;
int main() {
  scanf("%d%lf", &n, &p), p /= 1000000000;
  a[1][1] = p, a[1][2] = 1 - p;
  b[1][2] = 1 - p;
  for (int i = 2; i <= m; ++i) {
    a[i][1] = p, a[i][2] = 1 - p;
    b[i][2] = 1 - p;
    for (int j = 2; j <= m; ++j) {
      a[i][j] += a[i][j - 1] * a[i - 1][j - 1];
      b[i][j] += b[i][j - 1] * a[i - 1][j - 1];
    }
  }
  for (int i = m; i >= 1; --i)
    for (int j = 1; j <= m; ++j)
      a[i][j] *= 1 - a[i - 1][j], b[i][j] *= 1 - a[i - 1][j];
  f[1][1] = 1, f[1][2] = 2;
  for (int i = 2; i <= m; ++i) {
    for (int j = 2; j <= m; ++j) {
      double sum = 0;
      for (int k = 1; k < j; ++k)
        f[i][j] += f[i - 1][k] * a[i - 1][k], sum += a[i - 1][k];
      f[i][j] /= sum, f[i][j] += j;
    }
    double sum = 0;
    for (int k = 2; k <= m; ++k)
      f[i][1] += f[i - 1][k] * b[i - 1][k], sum += b[i - 1][k];
    f[i][1] /= sum, f[i][1] += 1;
  }
  double ans = 0;
  if (n <= m) {
    for (int i = 1; i <= m; ++i) ans += a[n][i] * f[n][i];
  } else {
    Ans.w[0][0] = trans.w[0][0] = 1;
    for (int i = 1; i <= m; ++i) trans.w[0][i] = i;
    for (int i = 2; i <= m; ++i) {
      double sum = 0;
      for (int j = 1; j < i; ++j) trans.w[j][i] += a[m][j], sum += a[m][j];
      for (int j = 1; j <= i; ++j) trans.w[j][i] /= sum;
    }
    double sum = 0;
    for (int i = 2; i <= m; ++i) trans.w[i][1] += b[m][i], sum += b[m][i];
    for (int i = 2; i <= m; ++i) trans.w[i][1] /= sum;
    for (int i = 1; i <= m; ++i) Ans.w[0][i] = f[m][i];
    int k = n - m;
    while (k) {
      if (k & 1) Ans *= trans;
      tmp = trans, trans *= tmp, k >>= 1;
    }
    for (int i = 1; i <= m; ++i) ans += Ans.w[0][i] * a[m][i];
  }
  printf("%.12lf", ans);
  return 0;
}
