#include <bits/stdc++.h>
using namespace std;
const int inf = 1000000000;
int Check(int N, int A, int B) {
  int Total = -1;
  while (B) {
    N -= A / B;
    Total += A / B - 1;
    A %= B;
    swap(A, B);
  }
  return (A == 1 && !N) ? Total : inf;
}
void Output(int A, int B) {
  static int X[1000000];
  int N = 0;
  while (B) {
    X[N++] = A / B;
    A %= B;
    swap(A, B);
  }
  X[N - 1]--;
  putchar('T');
  for (int i = 1; i <= N; i++)
    for (int j = 0; j < X[N - i]; j++) putchar((i & 1) ? 'B' : 'T');
  putchar('\n');
}
int main() {
  int N, M;
  scanf("%d%d", &N, &M);
  if (M == 1) {
    printf(N == 1 ? "0\nT\n" : "IMPOSSIBLE\n");
    return 0;
  }
  int Ans = inf, Best;
  for (int i = 1; i < M; i++) {
    int Temp = Check(N, M, i);
    if (Temp < Ans) {
      Ans = Temp;
      Best = i;
    }
  }
  if (Ans == inf)
    printf("IMPOSSIBLE\n");
  else {
    printf("%d\n", Ans);
    Output(M, Best);
  }
  return 0;
}
