#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000010;
int n, k, ans;
char s[maxn], t[maxn];
void dfs(int x, int y) {
  int len = 0;
  while (x != y) {
    if (x > y) {
      t[len++] = 'T';
      x -= y;
    } else {
      t[len++] = 'B';
      y -= x;
    }
  }
  if (x > 1) return;
  t[len++] = 'T';
  if (len != n) return;
  reverse(t, t + len);
  int cnt = 0;
  for (int i = 1; i < len; i++)
    if (t[i - 1] == t[i]) cnt++;
  if (cnt < ans) {
    ans = cnt;
    for (int i = 0; i < len; i++) s[i] = t[i];
    s[n] = '\n';
  }
}
int main() {
  scanf("%d%d", &n, &k);
  ans = 1 << 30;
  for (int i = 1; i <= k; i++) {
    dfs(i, k);
    dfs(k, i);
  }
  if (ans == 1 << 30)
    puts("IMPOSSIBLE");
  else {
    printf("%d\n%s\n", ans, s);
  }
  return 0;
}
