#include <bits/stdc++.h>
using namespace std;
int N, R, ans = 1 << 30;
string steps;
char dmy[1000005];
void solve(int x, int y) {
  int cur = N;
  while (x != y && cur > 0) {
    dmy[cur--] = (y >= x) ? 'T' : 'B';
    if (x > y)
      x -= y;
    else
      y -= x;
  }
  if (cur != 1 || x != 1) return;
  dmy[1] = 'T';
  cur = 0;
  for (int i = 1; i <= N - 1; i++) {
    cur += (dmy[i] == dmy[i + 1]);
  }
  if (cur >= ans) return;
  ans = cur;
  steps = "";
  for (int i = 1; i <= N; i++) {
    steps += (char)dmy[i];
  }
}
int main() {
  ios ::sync_with_stdio(false);
  cin >> N >> R;
  for (int i = 1; i <= R; i++) {
    solve(i, R);
    solve(R, i);
  }
  if (ans > N) {
    cout << "IMPOSSIBLE" << endl;
    return 0;
  }
  cout << ans << endl;
  cout << steps << endl;
  return 0;
}
