#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int n, r, ans = 1e9 + 5;
bool tmp[N], bit[N];
void solve1(int a, int b) {
  int cnt = 0;
  for (int i = n - 1; i >= 1; --i) {
    if (a < b) {
      tmp[i] = 1;
      b -= a;
    } else {
      tmp[i] = 0;
      a -= b;
    }
    if (a < 1 || b < 1) return;
  }
  if (a != 1 || b != 1) return;
  for (int i = 1; i < n; ++i) cnt += tmp[i] == tmp[i - 1];
  if (cnt >= ans) return;
  ans = cnt;
  for (int i = 0; i < n; ++i) bit[i] = tmp[i];
}
void solve2(int a, int b) {
  int cnt = 0;
  for (int i = n - 1; i >= 1; --i) {
    if (a < b) {
      tmp[i] = 0;
      b -= a;
    } else {
      tmp[i] = 1;
      a -= b;
    }
    if (a < 1 || b < 1) return;
  }
  if (a != 1 || b != 1) return;
  for (int i = 1; i < n; ++i) cnt += tmp[i] == tmp[i - 1];
  if (cnt >= ans) return;
  ans = cnt;
  for (int i = 0; i < n; ++i) bit[i] = tmp[i];
}
int main() {
  cin >> n >> r;
  for (int i = 1; i <= r; ++i) solve1(i, r), solve2(i, r);
  if (ans > n) return cout << "IMPOSSIBLE", 0;
  printf("%d\n", ans);
  for (int i = 0; i < n; ++i) printf("%c", bit[i] ? 'B' : 'T');
  return 0;
}
