#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int n;
int solve(int a, int b) {
  int steps = 0;
  int cost = 0;
  while (a + b != 1) {
    if (a > b) {
      cost += a / b - 1;
      steps += a / b;
      a %= b;
    } else {
      cost += b / a - 1;
      steps += b / a;
      b %= a;
    }
  }
  return steps == n ? cost : (int)1e9;
}
char ret[1000002];
int main() {
  int r;
  cin >> n >> r;
  int best = (int)1e9, bn = -1;
  for (int i = 1; i <= r; i++)
    if (gcd(i, r) == 1) {
      int c = solve(i, r);
      if (c == (int)1e9) continue;
      if (c < best) {
        best = c;
        bn = i;
      }
    }
  if (best == (int)1e9)
    printf("IMPOSSIBLE\n");
  else {
    int a = bn, b = r;
    for (int i = n - 1; i >= 0; i--) {
      if (a > b) {
        a -= b;
        ret[i] = 'T';
      } else {
        b -= a;
        ret[i] = 'B';
      }
    }
    if (ret[0] != 'T') {
      for (int i = 0; i < n; i++) ret[i] = (int)'T' + 'B' - ret[i];
    }
    if (n > 1 && ret[0] == ret[1]) {
      for (int i = 1; i < n; i++) ret[i] = (int)'T' + 'B' - ret[i];
    }
    int best = 0;
    for (int i = 1; i < n; i++)
      if (ret[i] == ret[i - 1]) best++;
    cout << best << endl;
    printf("%s\n", ret);
  }
  return 0;
}
