#include <bits/stdc++.h>
using namespace std;
char s[10];
int n, h;
double tw[100];
int main() {
  cin >> s >> n >> h;
  if (s[0] == 'B') {
    printf("%d\n", n);
    return 0;
  }
  tw[0] = 1;
  for (int i = 1; i <= 2 * h; i++) tw[i] = tw[i - 1] * 2.0;
  double r = n;
  for (int i = 1; i <= h; i++)
    for (int j = 1; j <= n; j++)
      r += ((double)n - (double)j) * (1 / tw[2 * i]) *
           pow(1 - 1 / tw[i], j - 1) *
           (tw[i] - tw[i - 1] * (1 + (j - 1) / (tw[i] - 1)));
  printf("%.9lf\n", r);
}
