#include <bits/stdc++.h>
using namespace std;
int al = 1 << 29;
char ans[1000100];
char a[1000100];
int n, m;
void computer(int x, int y) {
  int l = 0;
  while (x != y) {
    if (x > y) {
      a[l++] = 'T';
      x -= y;
    } else {
      a[l++] = 'B';
      y -= x;
    }
  }
  if (x > 1) return;
  a[l++] = 'T';
  if (l != n) return;
  reverse(a, a + l);
  int cur = 0;
  int i;
  for (i = 1; i < n; i++) {
    if (a[i - 1] == a[i]) cur++;
  }
  if (cur < al) {
    al = cur;
    for (i = 0; i < n; i++) ans[i] = a[i];
  }
}
int main() {
  int i;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= m; i++) {
    computer(i, m);
    computer(m, i);
  }
  if (al >= 1000100)
    cout << "IMPOSSIBLE" << endl;
  else {
    cout << al << endl;
    for (i = 0; i < n; i++) cout << ans[i];
    cout << endl;
  }
}
