#include <bits/stdc++.h>
using namespace std;
int n, h;
namespace Alice {
double ans = 0, f[35], g[35][30005], S, P;
void work() {
  int i, j;
  for (i = 1; i < h; i++) f[i] = pow(0.5, i);
  if (h > 1)
    f[h] = f[h - 1];
  else
    f[h] = 1;
  for (i = 0; i <= h; i++) g[i][0] = 1;
  for (i = 0; i <= h; i++) {
    P = i < h ? 1 - pow(0.5, i) : 1;
    for (j = 1; j <= n; j++) g[i][j] = g[i][j - 1] * P;
  }
  for (i = 1; i <= h; i++) {
    S = 0, P = pow(2, i);
    for (j = 0; j <= n - 2; j++)
      if (i < h)
        S += g[i - 1][j] * P * (1 - g[i][n - j - 1]);
      else
        S += g[i - 1][j] * (n - j - 1);
    for (j = i; j <= h; j++) ans += 2 * S * f[i] * f[j] * pow(2, i - 1);
    S = 0;
    for (j = 0; j <= n - 2; j++)
      S += g[i - 1][j] * g[i][n - j - 2] * (n - j - 1);
    ans -= f[i] * f[i] * pow(2, i - 1) * S;
  }
  printf("%.9lf", ans + 1);
}
};  // namespace Alice
int main() {
  char st[25];
  scanf("%s", st);
  scanf("%d %d", &n, &h), h++;
  if (st[0] == 'A')
    Alice::work();
  else
    printf("%d", n);
  return 0;
}
