#include <bits/stdc++.h>
using namespace std;
int A, B, C, Cans = 214748364, n, r, ansA, ansB;
bool f[1000010];
int gcd(int a, int b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
void Work() {
  int t, i, a = A, b = B;
  for (C = 0; A != 1 || B != 1;) {
    if (A > B) {
      f[++C] = 0;
      A -= B;
    } else {
      f[++C] = 1;
      B -= A;
    }
    if (C > n) break;
  }
  f[++C] = 0;
  if (C == n) {
    t = 0;
    for (int i = 2; i <= C; ++i)
      if (f[i] == f[i - 1]) ++t;
    if (t < Cans) Cans = t, ansA = a, ansB = b;
  }
}
void out() {
  if (Cans == 214748364)
    printf("IMPOSSIBLE\n");
  else {
    printf("%d\n", Cans);
    A = ansA, B = ansB;
    Work();
    for (int i = n; i >= 2; --i) printf("%c", f[i] ? 'B' : 'T');
    printf("%c\n", f[1] ? 'B' : 'T');
  }
}
int main() {
  int i;
  scanf("%d%d", &n, &r);
  for (int i = 1; i <= r; ++i)
    if (gcd(i, r) == 1) {
      A = i, B = r;
      Work();
      A = r, B = i;
      Work();
    }
  out();
  return 0;
}
