#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
const int maxn = 1e6 + 10, INF = 0x3f3f3f3f;
int N, R, ans;
char buff[maxn], res[maxn];
void solve(int, int);
int main() {
  while (~scanf("%d%d", &N, &R)) {
    ans = INF;
    for (int i = 1; i <= R; i++) {
      solve(i, R);
      solve(R, i);
    }
    if (ans == INF)
      puts("IMPOSSIBLE");
    else
      printf("%d\n%s\n", ans, res);
  }
  return 0;
}
void solve(int top, int bot) {
  for (int i = N - 1; i > 0; i--) {
    if (top == bot) return;
    if (top > bot) {
      top -= bot;
      buff[i] = 'T';
    } else {
      bot -= top;
      buff[i] = 'B';
    }
  }
  if (top != 1 || bot != 1) return;
  buff[0] = 'T';
  int cnt = 0;
  for (int i = 1; i < N; i++)
    if (buff[i - 1] == buff[i]) cnt++;
  if (cnt < ans) {
    ans = cnt;
    memcpy(res, buff, sizeof(buff[0]) * N);
    res[N] = 0;
  }
}
