#include <bits/stdc++.h>
using namespace std;
string st;
int n, h, pw1[35];
double ans, pw2[35];
double pw(double a, int b) {
  if (!b) return 1;
  double c = pw(a, b / 2);
  if (b & 1) return c * c * a;
  return c * c;
}
int main() {
  cin >> st;
  cin >> n >> h;
  if (st[0] == 'B') {
    cout << n << endl;
    return 0;
  }
  pw1[0] = 1;
  pw2[0] = 1;
  ans = n;
  for (int i = 1; i <= 30; i++)
    pw1[i] = pw1[i - 1] * 2, pw2[i] = pw2[i - 1] / 4.0;
  for (int i = 1; i <= h; i++)
    for (int j = 1; j <= n; j++) {
      double m1 = (n - j) * pw2[i] * pw(1 - 1.0 / pw1[i], j - 1);
      double m2 = pw1[i] - pw1[i - 1] * (1 + 1.0 * (j - 1) / (pw1[i] - 1));
      ans += m1 * m2;
    }
  printf("%.10f", ans);
}
