#include <bits/stdc++.h>
using namespace std;
const int maxn = 30000 + 15;
const int maxh = 30 + 5;
char ch[10];
int n, h;
double f[maxn][maxh][3], p[maxn][maxh][3], ff[maxh][3], pp[maxh][3],
    pe[maxh][3];
double gh[maxn][maxh][3];
double sumpe[maxh][3], sumgh[maxn][maxh][3], sumpp[maxh][3],
    sump[maxn][maxh][3];
double powe[maxh], sp[maxh];
int main() {
  scanf("%s%d%d", ch, &n, &h);
  if (ch[0] == 'B') {
    printf("%d\n", n);
    return 0;
  }
  double a = 1;
  for (int i = 0; i < h; i++) {
    a /= 2;
    powe[i] = a;
    p[1][i][2] = a;
  }
  powe[h] = a;
  sp[0] = powe[0];
  p[1][h][2] = a;
  for (int j = 0; j <= h; j++)
    for (int k = 0; k <= 2; k++) gh[1][j][k] = p[1][j][k] * (1 << j);
  for (int j = 1; j <= h; j++)
    for (int k = 1; k <= 2; k++)
      sumgh[1][j][k] = sumgh[1][j - 1][k] + gh[1][j][k];
  for (int j = 1; j <= h; j++)
    for (int k = 1; k <= 2; k++) sump[1][j][k] = sump[1][j - 1][k] + p[1][j][k];
  for (int i = 1; i <= h; i++) sp[i] = sp[i - 1] + powe[i];
  for (int i = 2; i <= n; i++) {
    for (int j = 0, k, l, x; j <= h; j++) {
      x = 1 << j;
      if (j != 0)
        f[i][j][0] = f[i - 1][j][0] * sp[j - 1] / powe[j],
        p[i][j][0] = p[i - 1][j][0] * sp[j - 1] / powe[j];
      f[i][j][0] += f[i - 1][j][0] + p[i - 1][j][0] * x;
      p[i][j][0] += p[i - 1][j][0];
      for (l = j + 1; l <= h; l++)
        for (k = 0; k <= 2; k++) {
          f[i][j][0] += f[i - 1][l][k] + p[i - 1][l][k] * x;
          p[i][j][0] += p[i - 1][l][k];
        }
      if (j != 0) f[i][j][1] += pe[j][1], p[i][j][1] += pp[j][1];
      f[i][j][1] += f[i - 1][j][1] + p[i - 1][j][1] * x;
      p[i][j][1] += p[i - 1][j][1];
      if (j != 0)
        for (k = 1; k <= 2; k++) {
          f[i][j][1] += gh[i - 1][0][k];
          p[i][j][1] += p[i - 1][0][k];
        }
      if (j > 1)
        f[i][j][1] += sumpe[j - 1][1] + sumpe[j - 1][2] +
                      sumgh[i - 1][j - 1][1] + sumgh[i - 1][j - 1][2];
      if (j > 1)
        p[i][j][1] += sumpp[j - 1][1] + sumpp[j - 1][2] +
                      sump[i - 1][j - 1][1] + sump[i - 1][j - 1][2];
      x = 1 << j;
      if (j != 0) f[i][j][2] += ff[j][2] + pp[j][2] * x, p[i][j][2] += pp[j][2];
      f[i][j][2] += f[i - 1][j][2] + p[i - 1][j][2] * x;
      p[i][j][2] += p[i - 1][j][2];
      f[i][j][0] *= powe[j];
      f[i][j][1] *= powe[j];
      f[i][j][2] *= powe[j];
      p[i][j][0] *= powe[j];
      p[i][j][1] *= powe[j];
      p[i][j][2] *= powe[j];
    }
    for (int j = 1; j <= h; j++)
      for (int k = 0; k <= 2; k++)
        ff[j][k] += f[i - 1][j][k], pp[j][k] += p[i - 1][j][k];
    for (int j = 1; j <= h; j++)
      for (int k = 0; k <= 2; k++) ff[j][k] *= sp[j - 1], pp[j][k] *= sp[j - 1];
    for (int j = 1; j <= h; j++)
      for (int k = 1; k <= 2; k++)
        sumpp[j][k] = sumpp[j - 1][k] + pp[j][k],
        sump[i][j][k] = sump[i][j - 1][k] + p[i][j][k];
    for (int j = 0; j <= h; j++)
      for (int k = 0; k <= 2; k++)
        pe[j][k] = pp[j][k] * (1 << j) + ff[j][k],
        gh[i][j][k] = p[i][j][k] * (1 << j) + f[i][j][k];
    for (int j = 1; j <= h; j++)
      for (int k = 1; k <= 2; k++)
        sumpe[j][k] = sumpe[j - 1][k] + pe[j][k],
        sumgh[i][j][k] = sumgh[i][j - 1][k] + gh[i][j][k];
  }
  double ans = 0;
  for (int i = 0; i <= h; i++)
    for (int j = 0; j <= 2; j++) ans += f[n][i][j];
  printf("%.9lf\n", ans + 1);
  return 0;
}
