package main
import (
"bufio"
"fmt"
"os"
"strconv"
)
func maxRunsFromCF(first, last, length int) int {
if length == 1 {
if first == 1 {
return 1
}
if first == 2 {
return 2
}
return 3
}
runs := length
if first > 1 {
runs++
}
if last > 1 {
runs++
}
return runs
}
func getCF(r, q int) []int {
res := make([]int, 0, 32)
for q != 0 {
res = append(res, r/q)
r, q = q, r%q
}
return res
}
func buildRuns(cf []int) []int {
t := len(cf)
if t == 1 {
x := cf[0]
if x == 1 {
return []int{1}
}
if x == 2 {
return []int{1, 1}
}
return []int{1, x - 2, 1}
}
res := make([]int, 0, t+2)
if cf[0] > 1 {
res = append(res, 1, cf[0]-1)
} else {
res = append(res, 1)
}
for i := 1; i < t-1; i++ {
res = append(res, cf[i])
}
if cf[t-1] > 1 {
res = append(res, cf[t-1]-1, 1)
} else {
res = append(res, 1)
}
return res
}
func main() {
in := bufio.NewReaderSize(os.Stdin, 1<<20)
out := bufio.NewWriterSize(os.Stdout, 1<<20)
defer out.Flush()
var n, r int
if _, err := fmt.Fscan(in, &n, &r); err != nil {
return
}
if n == 1 && r == 1 {
out.WriteString("0\nT\n")
return
}
if n > r || r < 1 || n < 1 {
out.WriteString("IMPOSSIBLE\n")
return
}
bestRuns := -1
bestQ := -1
for q := 1; q < r; q++ {
a, b := r, q
sum := 0
length := 0
first := 0
last := 0
ok := true
for b != 0 {
quo := a / b
sum += quo
if sum > n {
ok = false
break
}
length++
if length == 1 {
first = quo
}
last = quo
a, b = b, a%b
}
if !ok || a != 1 || sum != n {
continue
}
runs := maxRunsFromCF(first, last, length)
if runs > bestRuns {
bestRuns = runs
bestQ = q
if bestRuns == n {
break
}
}
}
if bestQ == -1 {
out.WriteString("IMPOSSIBLE\n")
return
}
cf := getCF(r, bestQ)
runs := buildRuns(cf)
mistakes := n - len(runs)
ops := make([]byte, n)
pos := 0
ch := byte('T')
for _, cnt := range runs {
for i := 0; i < cnt; i++ {
ops[pos] = ch
pos++
}
if ch == 'T' {
ch = 'B'
} else {
ch = 'T'
}
}
out.WriteString(strconv.Itoa(mistakes))
out.WriteByte('\n')
out.Write(ops)
out.WriteByte('\n')
}