#include <bits/stdc++.h>
using namespace std;
int targetOps, result;
void readInput() {
  scanf("%d %d", &targetOps, &result);
  targetOps--;
}
bool opswap[1000001];
bool bestOpswap[1000001];
char opstring[1000001];
int ops;
int mistakes;
int minMistakes = 1234567;
bool fail = false;
void countOps(int a, int b) {
  ops = 0;
  mistakes = -1;
  while (a != b) {
    if (a < b) {
      int t = a;
      a = b;
      b = t;
      opswap[ops] = true;
    } else {
      opswap[ops] = false;
      mistakes++;
    }
    a -= b;
    ops++;
  }
  fail = (a > 1);
}
void solve() {
  if (targetOps == 0 && result == 1) {
    minMistakes = 0;
  }
  for (int other = 1; other < result; other++) {
    countOps(result, other);
    if (!fail) {
      if (ops == targetOps) {
        if (mistakes < minMistakes) {
          minMistakes = mistakes;
          for (int i = 0; i < ops; i++) {
            bestOpswap[i] = opswap[i];
          }
        }
      }
    }
  }
}
void printSolution() {
  if (minMistakes == 1234567) {
    printf("IMPOSSIBLE");
  } else {
    printf("%d\n", minMistakes);
    printf("T");
    bool lastSwap = true;
    bool top = true;
    for (int i = 0; i < targetOps; i++) {
      top ^= lastSwap;
      printf("%c", (top ? 'T' : 'B'));
      lastSwap = bestOpswap[targetOps - i - 1];
    }
  }
}
int main() {
  readInput();
  solve();
  printSolution();
}
