#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:60777216")
using namespace std;
int err;
vector<char> best;
vector<char> curr;
int n, r;
int it;
void go(int pos, int f1, int f2, int errors) {
  if (err <= errors) return;
  if (pos == -1) {
    err = errors;
    best = curr;
  } else {
    if (f1 == f2) {
      curr[pos] = 'T';
      go(-1, 0, 0, errors + (pos + 1 < n && curr[pos + 1] == curr[pos]));
    } else if (f1 > f2) {
      curr[pos] = 'T';
      go(pos - 1, f1 - f2, f2,
         errors + (pos + 1 < n && curr[pos + 1] == curr[pos]));
    } else {
      curr[pos] = 'B';
      go(pos - 1, f1, f2 - f1,
         errors + (pos + 1 < n && curr[pos + 1] == curr[pos]));
    }
  }
}
int gcd(int a, int b) {
  while (a && b)
    if (a > b)
      a %= b;
    else
      b %= a;
  return a + b;
}
int ngcd(int a, int b) {
  int res = 0;
  while (a && b)
    if (a > b)
      res += a / b, a %= b;
    else
      res += b / a, b %= a;
  return res;
}
int main() {
  cin >> n >> r;
  vector<int> nm;
  for (int other = 1; other <= r; other++) {
    int g = gcd(other, r);
    if (g == 1) {
      int t = ngcd(other, r);
      if (t == n) {
        nm.push_back(other);
      }
    }
  }
  if (nm.size() == 0)
    puts("IMPOSSIBLE");
  else {
    err = n + 1;
    curr.resize(n);
    for (int i = (0); i < (nm.size()); i++) {
      go(n - 1, r, nm[i], 0);
      go(n - 1, nm[i], r, 0);
    }
    cout << err << endl;
    for (int i = (0); i < (best.size()); i++) printf("%c", best[i]);
    puts("");
  }
  return 0;
}
