#include <bits/stdc++.h>
using namespace std;
const int nMax = 1000010;
const int MAX = 0x7fffffff;
char ans[nMax], tans[nMax];
int n, len, Min;
int f[nMax];
void doit(int t, int b) {
  int i, temp = 0, tt = t, tb = b;
  for (i = len - 1; i >= 0 && t * b; i--)
    if (t >= b)
      tans[i] = 'T', t -= b;
    else
      tans[i] = 'B', b -= t;
  if (i != -1 || b != 1 || t) return;
  for (i = 1; i < len; i++)
    if (tans[i] == tans[i - 1]) temp++;
  if (temp < Min) {
    memcpy(ans, tans, sizeof(tans));
    Min = temp;
  }
}
int main() {
  int i, j;
  while (scanf("%d%d", &len, &n) != EOF) {
    ans[len] = '\0';
    Min = MAX;
    for (i = 1; i <= n; i++) doit(i, n), doit(n, i);
    if (Min == MAX) {
      printf("IMPOSSIBLE\n");
      continue;
    }
    printf("%d\n%s\n", Min, ans);
  }
  return 0;
}
