#include <bits/stdc++.h>
using namespace std;
char S[10];
double P[35];
double power(double a, int b) {
  double ans = 1;
  for (; b; b >>= 1, a *= a)
    if (b & 1) ans *= a;
  return ans;
}
int main() {
  int n, h;
  scanf("%s%d%d", S, &n, &h), P[0] = 1;
  for (int i = 1; i <= 30; ++i) P[i] = P[i - 1] * 2;
  if (S[0] == 'B')
    printf("%.9lf\n", (double)n);
  else {
    double ans = n;
    for (int i = 1; i <= n; ++i)
      for (int j = 1; j <= h; ++j)
        ans += (n - i) / P[j] / P[j] * power(1.0 - 1.0 / P[j], i - 1) *
               (P[j] - P[j - 1] * (1.0 + (i - 1) / (P[j] - 1)));
    printf("%.9lf\n", ans);
  }
  return 0;
}
