#include <bits/stdc++.h>
int len, n, m;
char opt[2000005];
int dfs(int A, int B) {
  while (1) {
    if (A >= B)
      opt[++len] = 'T', A -= B;
    else
      opt[++len] = 'B', B -= A;
    if (!A || !B) return A ^ B;
    if (len > n) return -1;
  }
}
int ans = 0x7f7f7f7f, ansx, ansy;
void work(int A, int B) {
  len = 0;
  if (dfs(A, B) == 1 && opt[len] == 'T' && len == n) {
    int res = 0;
    for (int i = 1; i < len; i++)
      if (opt[i] == opt[i + 1]) res++;
    if (res < ans) {
      ans = res;
      ansx = A;
      ansy = B;
    }
  }
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= m; i++) work(i, m), work(m, i);
  if (ans == 0x7f7f7f7f) {
    printf("IMPOSSIBLE\n");
    return 0;
  }
  printf("%d\n", ans);
  work(ansx, ansy);
  for (int i = len; i >= 1; i--) printf("%c", opt[i]);
}
