#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
void wa(int a, int b, int &mis, int &step) {
  if (b == 1) {
    mis += a - 1;
    step += a;
    return;
  }
  step += a / b;
  mis += a / b - 1;
  wa(b, a % b, mis, step);
}
void get(int a, int b, string &s) {
  if (b == 1) {
    for (int i = 1; i < a; i++) s += 'B';
    return;
  }
  get(b, a % b, s);
  char ch = s[s.size() - 1] == 'T' ? 'B' : 'T';
  for (int i = 0; i < a / b; i++) s += ch;
}
void slove(int n, int r) {
  int m = 1000000000;
  int num;
  for (int i = r - 1; i >= 1; i--) {
    if (gcd(i, r) == 1) {
      int mis = 0;
      int step = 0;
      wa(r, i, mis, step);
      if (step == n && mis < m) {
        num = i;
        m = mis;
      }
    }
  }
  if (m != 1000000000) {
    cout << m - 1 << endl;
    string s = "T";
    get(r, num, s);
    cout << s << endl;
  } else
    cout << "IMPOSSIBLE" << endl;
}
int main() {
  int n, r;
  while (cin >> n >> r)
    if (n == 1 && r == 1) {
      cout << "0" << endl;
      cout << "T" << endl;
    } else
      slove(n, r);
}
