#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return (a == 0 ? b : gcd(b % a, a)); }
void print(int opt, pair<int, int> ans) {
  printf("%d\n", opt);
  vector<char> output;
  int a = ans.first, b = ans.second;
  while (a != 1 || b != 1) {
    if (a > b) {
      a -= b;
      output.push_back('T');
    } else if (b > a) {
      b -= a;
      output.push_back('B');
    }
  }
  output.push_back('T');
  for (int i = output.size() - 1; i >= 0; --i) putchar(output[i]);
  putchar('\n');
}
int main() {
  int n, r;
  int opt = 1000006;
  pair<int, int> ans;
  scanf("%d%d", &n, &r);
  if (n == 1 && r == 1) {
    printf("0\nT\n");
    return 0;
  }
  for (int i = 1; i < r; ++i) {
    if (gcd(i, r) != 1) continue;
    int step = n, a = i, b = r, cnt = 0, q;
    char last = 'B';
    while (a != 1 || b != 1) {
      if (a > b) {
        q = (b == 1 ? a - 1 : a / b);
        a -= q * b;
        last = 'T';
      } else if (b > a) {
        q = (a == 1 ? b - 1 : b / a);
        b -= q * a;
        last = 'B';
      }
      cnt += q - 1;
      step -= q;
    }
    if (step == 1) {
      if (cnt < opt) {
        if (last == 'B')
          ans = make_pair(i, r);
        else
          ans = make_pair(r, i);
        opt = cnt;
      }
    }
  }
  if (opt == 1000006)
    printf("IMPOSSIBLE\n");
  else
    print(opt, ans);
  return 0;
}
