#include <bits/stdc++.h>
using namespace std;
int n, p;
double dp[110][110], dp2[110][110], prob[110][110], prob2[110][110];
double pw[110];
const int matdim = 50 * 2 + 5;
double m[matdim][matdim], vec[matdim], rez[matdim][matdim];
bool ok = false;
void mult(double a[][matdim], double b[][matdim], double c[][matdim]) {
  double temp[matdim][matdim];
  memset(temp, 0, sizeof(temp));
  for (int i = 1; i < matdim; ++i) {
    for (int j = 1; j < matdim; ++j) {
      for (int k = 1; k < matdim; ++k) {
        temp[i][j] += b[i][k] * c[k][j];
      }
    }
  }
  memcpy(a, temp, sizeof(temp));
}
void mult(double vec[], double a[][matdim]) {
  double newvec[matdim];
  memset(newvec, 0, sizeof(newvec));
  for (int i = 1; i < matdim; ++i) {
    for (int j = 1; j < matdim; ++j) {
      newvec[j] += vec[i] * a[i][j];
    }
  }
  memcpy(vec, newvec, sizeof(newvec));
}
void pow(double m[][matdim], int k, double rez[][matdim]) {
  for (int i = 1; i < matdim; ++i) {
    for (int j = 1; j < matdim; ++j) {
      if (i == j)
        rez[i][j] = 1;
      else
        rez[i][j] = 0;
    }
  }
  for (int p = 0; (1 << p) <= k; ++p) {
    if ((k >> p) & 1) {
      mult(rez, rez, m);
    }
    mult(m, m, m);
  }
}
int main() {
  cin >> n >> p;
  cout << fixed << setprecision(15);
  dp[1][1] = 1.0 * p / 1000000000;
  prob[1][1] = 1.0 * p / 1000000000;
  dp[1][2] = 2.0 * (1000000000 - p) / 1000000000;
  prob[1][2] = 1.0 * (1000000000 - p) / 1000000000;
  dp2[1][1] = 0;
  prob2[1][1] = 0;
  dp2[1][2] = 2;
  prob2[1][2] = 1;
  long long p1 = 1LL * (1000000000 - p) * 1000000000 + 1LL * p * p;
  long long p2 = 1LL * p * (1000000000 - p);
  long long nnum = 1LL * 1000000000 * 1000000000;
  double pp1 = 1.0 * (1000000000 - p) / 1000000000 +
               1.0 * p / 1000000000 * p / 1000000000;
  double pp2 = 1.0 * p / 1000000000 * (1000000000 - p) / 1000000000;
  pw[0] = pp1;
  for (int j = 1; j <= 50; ++j) pw[j] = pw[j - 1] * pw[j - 1];
  for (int i = 2; i <= 50; ++i) {
    for (int j = 1; j <= i + 1 && j <= 50; ++j) {
      if (j == 1) {
        for (int k = 1; k <= 50; ++k) {
          dp[i][j] += dp2[i - 1][k] * pp2;
          dp[i][j] += prob2[i - 1][k] * pp2;
          prob[i][j] += prob2[i - 1][k] * pp2;
        }
      } else {
        double coef1, coef2;
        if (j <= i) {
          coef1 = pw[j - 2];
          coef2 = pw[j - 2] / pw[0];
        } else {
          coef1 = pw[j - 2] / pw[0] * (1.0 * (1000000000 - p) / 1000000000);
          coef2 = pw[j - 2] / pw[1] * (1.0 * (1000000000 - p) / 1000000000);
        }
        for (int k = 1; k < j; ++k) {
          dp[i][j] += dp[i - 1][k] * coef1;
          dp[i][j] += prob[i - 1][k] * coef1 * j;
          prob[i][j] += prob[i - 1][k] * coef1;
          dp2[i][j] += dp[i - 1][k] * coef2;
          dp2[i][j] += prob[i - 1][k] * coef2 * j;
          prob2[i][j] += prob[i - 1][k] * coef2;
        }
      }
    }
  }
  for (int j = 1; j <= 50; ++j) {
    if (j == 1) {
      for (int k = 1; k <= 50; ++k) {
        m[k + 50][j] += pp2;
        m[2 * 50 + 1][j] += pp2 * prob2[50][k];
      }
    } else {
      double coef1 = pw[j - 2];
      double coef2 = pw[j - 2] / pw[0];
      for (int k = 1; k < j; ++k) {
        m[k][j] += coef1;
        m[2 * 50 + 1][j] += prob[50][k] * coef1 * j;
        m[k][j + 50] += coef2;
        m[2 * 50 + 1][j + 50] += prob[50][k] * coef2 * j;
      }
    }
  }
  m[2 * 50 + 1][2 * 50 + 1] = 1;
  double tans = 0;
  for (int j = 1; j <= 50; ++j) tans += dp[50][j];
  double ans = 0;
  if (n <= 50) {
    for (int j = 1; j <= 50; ++j) ans += dp[n][j];
  } else {
    for (int j = 1; j <= 50; ++j) {
      vec[j] = dp[50][j];
      vec[j + 50] = dp2[50][j];
    }
    vec[2 * 50 + 1] = 1;
    int ret = n;
    int cap = 250000;
    n = min(n, cap);
    pow(m, n - 50, rez);
    mult(vec, rez);
    for (int j = 1; j <= 50; ++j) ans += vec[j];
    if (ret > cap) ans = ans / cap * ret;
  }
  cout << ans << "\n";
  return 0;
}
