#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1E6 + 10;
int N, R;
char str[MAXN];
int res = 1E9;
char tmp[MAXN];
int len = 0;
void go(int a, int b) {
  len = 0;
  char prv = 0;
  int cnt = 0;
  while (a != 0 && b != 0) {
    if (a == 1 && b == 1) {
      if (len == N - 1) {
        if (len >= 1 && tmp[len - 1] == 'T') ++cnt;
        if (cnt < res) {
          copy(tmp, tmp + len, str);
          res = cnt;
        }
      }
      break;
    }
    char cur = 0;
    if (a < b) {
      b -= a;
      cur = 'B';
    } else {
      a -= b;
      cur = 'T';
    }
    cnt += (prv == cur);
    prv = cur;
    tmp[len++] = cur;
  }
}
int main() {
  scanf("%d %d", &N, &R);
  for (int i = 1; i <= R; ++i) {
    go(i, R);
    go(R, i);
  }
  if (res < 1E9) {
    printf("%d\n", res);
    str[N - 1] = 'T';
    for (int i = N - 1; i >= 0; --i) {
      printf("%c", str[i]);
    }
  } else {
    printf("IMPOSSIBLE\n");
  }
  return 0;
}
