#include <bits/stdc++.h>
int n, r, cur, best = 1000000;
char s[1000000 + 1], bs[1000000 + 1];
int gcd(int a, int b) { return !b ? a : gcd(b, a % b); }
bool divide(int a, int b) {
  if (b == 0) {
    s[cur++] = 'T';
    return 0;
  }
  int cnt = 0;
  char ch = 'B';
  cnt = a / b;
  if (b == 1) --cnt;
  if (divide(b, a % b)) ch = 'T';
  while (cnt--) s[cur++] = ch;
  return !(ch == 'T');
}
int main() {
  scanf("%d%d", &n, &r);
  for (int i = r - 1; i; --i) {
    int ret = gcd(r, i);
    if (ret == 1) {
      cur = 0;
      divide(r, i);
      if (cur != n) continue;
      int ans = 0;
      for (int i = 1; i < n; ++i) ans += s[i - 1] == s[i];
      if (ans < best) best = ans, memcpy(bs, s, sizeof(char) * (n + 1));
    }
  }
  if (n == 1 && r == 1)
    printf("0\nT\n");
  else if (best == 1000000)
    printf("IMPOSSIBLE\n");
  else {
    bs[n] = 0;
    printf("%d\n", best);
    fwrite(bs, sizeof(char), sizeof(char) * n, stdout);
  }
  return 0;
}
