#include <bits/stdc++.h>
using namespace std;
int n, r, a[1000001], ans[1000001], Min = 2147483647;
void search(int x, int y) {
  int count = 0;
  while (x != y) {
    count++;
    if (count == n) return;
    if (x > y) {
      a[count] = 0;
      x -= y;
    } else {
      a[count] = 1;
      y -= x;
    }
  }
  if (x != 1) return;
  count++;
  a[count] = 0;
  if (count != n) return;
  int calc = 0;
  for (int i = 1; i < n; i++)
    if (a[i] == a[i + 1]) calc++;
  if (calc < Min) {
    Min = calc;
    for (int i = 1; i <= n; i++) ans[i] = a[i];
  }
  return;
}
int main() {
  cin >> n >> r;
  for (int i = 1; i <= r; i++) {
    search(i, r);
    search(r, i);
  }
  if (Min == 2147483647)
    cout << "IMPOSSIBLE" << endl;
  else {
    cout << Min << endl;
    for (int i = n; i >= 1; i--)
      if (ans[i] == 0)
        cout << "T";
      else
        cout << "B";
    cout << endl;
  }
  return 0;
}
