#include <bits/stdc++.h>
using namespace std;
char buf[2000010];
int func(int t, int b) {
  int ans = 0;
  while (t > 0 && b > 0) {
    if (t >= b) {
      ans += t / b;
      t %= b;
    } else {
      ans += (b - 1) / t;
      b -= (b - 1) / t * t;
    }
  }
  if (t == 0 && b == 1) return ans;
  return -1;
}
int func2(int t, int b) {
  int i = 0;
  while (t > 0 && b > 0) {
    if (t >= b) {
      buf[i] = 'T';
      t -= b;
      i++;
    } else {
      buf[i] = 'B';
      b -= t;
      i++;
    }
  }
  int len = i;
  reverse(buf, buf + len);
  int mistake = 0;
  for ((i) = 0; (i) < (int)(len - 1); (i)++)
    if (buf[i] == buf[i + 1]) mistake++;
  if (buf[0] != 'T') mistake = (1 << 29);
  return mistake;
}
int main(void) {
  int n, r, i;
  cin >> n >> r;
  int x = -1, y = -1, best = (1 << 29);
  for ((i) = 0; (i) < (int)(r + 1); (i)++)
    if (func(r, i) == n) {
      int tmp = func2(r, i);
      if (tmp < best) {
        best = tmp;
        x = r;
        y = i;
      }
    }
  for ((i) = 0; (i) < (int)(r); (i)++)
    if (func(i, r) == n) {
      int tmp = func2(i, r);
      if (tmp < best) {
        best = tmp;
        x = i;
        y = r;
      }
    }
  if (best == (1 << 29)) {
    cout << "IMPOSSIBLE" << endl;
  } else {
    func2(x, y);
    buf[n] = '\0';
    cout << best << endl;
    printf("%s\n", buf);
  }
  return 0;
}
