#include <bits/stdc++.h>
using namespace std;
const int MAXN = 30100;
const int MAXH = 32;
string str;
int N, H;
long double dp[MAXN][MAXH];
long double ppart[MAXN][MAXH];
long double prob[MAXH];
long double res[MAXH];
int main() {
  cin >> str;
  cin >> N >> H;
  if (str[0] == 'B') {
    cout << N << "\n";
    return 0;
  }
  for (int i = 0; i < MAXN; i++) dp[i][0] = i;
  for (int i = 1; i < MAXH; i++) {
    dp[0][i] = ppart[0][i] = 0.0;
    long double ptot = 0.5;
    prob[0] = 0.5;
    for (int j = 1; j <= i; j++) {
      prob[j] = prob[j - 1] / 2.0;
      ptot += prob[j];
    }
    for (int j = 0; j <= i; j++) prob[j] *= 1.0 / ptot;
    long double pnone = 1.0;
    for (int j = 1; j < MAXN; j++) {
      long double nnone = pnone * (1.0 - prob[i]);
      dp[j][i] = nnone * dp[j][i - 1] +
                 (pnone - nnone) * (dp[j - 1][i - 1] + (1 << i)) +
                 ppart[j - 1][i] + prob[i] * (1.0 - pnone) * (1 << i);
      ppart[j][i] = dp[j][i] - nnone * dp[j][i - 1];
      pnone = nnone;
    }
  }
  res[0] = N - 1;
  for (int i = 1; i <= H; i++) {
    long double ptot = 0.5;
    prob[0] = 0.5;
    for (int j = 1; j <= i; j++) {
      prob[j] = prob[j - 1] / 2.0;
      ptot += prob[j];
    }
    if (i == H) {
      ptot = 1.0;
      prob[i] *= 2.0;
    }
    for (int j = 0; j <= i; j++) prob[j] *= 1.0 / ptot;
    long double none = 1.0;
    for (int j = 0; j < N; j++) none *= (1.0 - prob[i]);
    res[i] = none * res[i - 1];
    res[i] += (1.0 - none) * ((N * prob[i] / (1.0 - none) - 1) * (1 << i));
    long double pprob = prob[i];
    for (int j = 0; j < N; j++) {
      res[i] += pprob * 2.0 * dp[j][i - 1];
      pprob *= (1.0 - prob[i]);
    }
  }
  cout << fixed << setprecision(10);
  cout << res[H] + 1.0 << "\n";
  return 0;
}
