#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:128000000")
int n, k;
vector<pair<int, int> > miner;
int minval = 1e9, curval;
vector<pair<int, int> > cur;
inline bool calc(int a) {
  cur.clear();
  int b = k;
  int len = 0, t;
  curval = 0;
  while (a && b) {
    if (a == 1 && b == 1) {
      if (cur.size() > 0)
        cur.push_back(make_pair(1, !cur.back().second));
      else
        cur.push_back(make_pair(1, 0));
      len++;
      a = 0;
      b = 1;
      break;
    }
    if (a > b) {
      t = a / b;
      if (b == 1) t--;
      cur.push_back(make_pair(t, 0));
      a -= b * t;
      len += t;
      curval += t - 1;
    } else {
      t = b / a;
      if (a == 1) t--;
      cur.push_back(make_pair(t, 1));
      b -= a * t;
      len += t;
      curval += t - 1;
    }
  }
  if (a == 0 && b == 1 || a == 1 && b == 0) {
    if (len != n) return false;
    return true;
  }
  return false;
}
int main() {
  cin >> n >> k;
  for (int i = 0; i <= k; i++) {
    if (calc(i)) {
      if (curval < minval) {
        minval = curval;
        miner = cur;
      }
    }
  }
  char f = 'T', s = 'B';
  if (miner.empty())
    cout << "IMPOSSIBLE";
  else {
    if (miner[miner.size() - 1].second != 0) swap(f, s);
    cout << minval << endl;
    for (int i = miner.size() - 1; i >= 0; i--)
      for (int j = 0; j < miner[i].first; j++)
        if (miner[i].second)
          putchar(s);
        else
          putchar(f);
  }
  return 0;
}
