#include <bits/stdc++.h>
using namespace std;
int n;
string s;
int h;
double dp[30007][33][2], fp[30007][33][2];
void add(double& x, double y) { x = x + y; }
signed main() {
  cin >> s >> n >> h;
  if (s[0] == 'B') {
    double cn = n;
    printf("%.12lf\n", cn);
  } else {
    double ans = n;
    for (int i = 1; i <= h; i++)
      for (int j = 1; j <= n; j++) {
        double p = 1 / (pow(2, i) - 1);
        ans += (n - j) * pow(0.5, i + i) * pow(1 - pow(0.5, i), j - 1) *
               (pow(2, i) - pow(2, i - 1) * (1 + p * (j - 1)));
      }
    printf("%.12lf\n", ans);
  }
  return 0;
}
