#include <iostream>
using namespace std;
int bol[1000001];
char a[1000001];
char b[1000001];
int ok,n,m;
int M;
int mt(int ,int);
int main()
{
    int i=0,j,t;
    int fs=0,fe=1;
    int MIN=1000001;
    while(fe<=1000000)
    {
         t=fe;
         fe=fs+fe;
         fs=t;
         bol[i++]=fe;
    }
    cin>>n>>m;
    n--;
    a[n+1]='T';
    int l=n;
    for(i=m-1;i>0;i--)
    {
       n=l;
       ok=M=0;
        mt(m,i);
       if(ok&&M<MIN)
       {
         for(j=0;j<=l;j++)
          b[j]=a[j];
         MIN=M;
       }
    }
    if(b[0]!='\0')
    {
       cout<<MIN<<endl;
       for(i=0;i<=l;i++)
          cout<<b[i];
    }
    else
       cout<<"IMPOSSIBLE";
   cout<<endl;
   return 0;
}
int mt(int end,int start)
{
    int i;
    if(end==start)
      return 0;
    if(end<start)
     {
       a[n]=a[n+1];
       int t=start;
       start=end;
       end=t;
       M++;
     }
    else
    {
         if(a[n+1]=='T')
           a[n]='B';
         else
           a[n]='T';
    }
    if(bol[n]==end&&bol[n-1]==start)
    {
      for(i=0;i<n;i++)
        if(i%2)
          a[i]='B';
        else
          a[i]='T';
      if(a[n-2]==a[n-1])
       M++;
      ok=1;
      return 0;
    }
    if(n==1)
     return 0;
    n--;
    int t=start;
    start=end-t;
    end=t;
    mt(end,start);
    return 0;
}


#include <iostream>
using namespace std;
int bol[1000001];
char a[1000001];
char b[1000001];
int ok,n,m;
int M;
int l;
int mt(int ,int);
int main()
{
    int i=0,j,t;
    int fs=0,fe=1;
    int MIN=1000001;
    while(fe<=1000000)
    {
         t=fe;
         fe=fs+fe;
         fs=t;
         bol[i++]=fe;
    }
    cin>>n>>m;
    if(n==1&&m==1)
    {
       cout<<"0"<<endl;
       cout<<'T'<<endl;
       return 0;
    }
    n--;
    a[n+1]='B';
    l=n;
    for(i=m-1;i>0;i--)
    {
       n=l;
       ok=M=0;
        mt(m,i);
       if(ok&&M<MIN)
       {
         for(j=0;j<=l;j++)
          b[j]=a[j];
         MIN=M;
       }
    }
    if(b[0]!='\0')
    {
       cout<<MIN<<endl;
       for(i=0;i<=l;i++)
          cout<<b[i];
    }
    else
       cout<<"IMPOSSIBLE";
   cout<<endl;
   return 0;
}
int mt(int end,int start)
{
    int i;
    if(end==start)
      return 0;
    if(end<start)
     {
       a[n]=a[n+1];
       int t=start;
       start=end;
       end=t;
       M++;
     }
    else
    {
         if(a[n+1]=='T')
           a[n]='B';
         else
           a[n]='T';
    }
    if(bol[n]==end&&bol[n-1]==start)
    {
      for(i=0;i<n;i++)
        if(i%2)
          a[i]='B';
        else
          a[i]='T';
      if(a[n]==a[n-1])
      {
         for(i=n;i<=l;i++)
         {
            if(a[i]=='B')
              a[i]='T';
            else
              a[i]='B';
         }
      }
      ok=1;
      return 0;
    }
    if(n==1)
     return 0;
    n--;
    int t=start;
    start=end-t;
    end=t;
    mt(end,start);
    return 0;
}


#include <iostream>
using namespace std;
int bol[1000001];
char a[1000001];
int ok,n,m;
int mt(int ,int);
int main()
{
    int i=0,j,t;
    int fs=0,fe=1;
    while(fe<=1000000)
    {
         t=fe;
         fe=fs+fe;
         fs=t;
         bol[i++]=fe;
    }
    cin>>n>>m;
    n--;
    if((n+1)%2)
       a[n+1]='B';
    else
       a[n+1]='T';
    int l=n;
    for(i=bol[n-1];i>m/2;i--)
    {
       n=l;
       if(m>i)
        mt(m,i);
       if(ok)
        break;
    }
    int min=0;
    if(ok)
    {
       for(i=0;i<=l;i++)
         if(i%2)
         {
            if(a[i]!='B')
              min++;
         }
         else
         {
            if(a[i]!='T')
              min++;
         }
       cout<<min<<endl;
       for(i=0;i<=l;i++)
          cout<<a[i];
    }
    else
       cout<<"IMPOSSIBLE";
   cout<<endl;
   return 0;
}
int mt(int end,int start)
{
    int i;
    if(end==start)
      return 0;
    if(end<start)
     {
       a[n]=a[n+1];
       int t=start;
       start=end;
       end=t;
     }
    else
    {
         if(a[n+1]=='T')
           a[n]='B';
         else
           a[n]='T';
    }
    if(bol[n]==end&&bol[n-1]==start)
    {
      for(i=0;i<n;i++)
        if(i%2)
          a[i]='B';
        else
          a[i]='T';
      ok=1;
      return 0;
    }
    if(n==1)
     return 0;
    n--;
    int t=start;
    start=end-t;
    end=t;
    mt(end,start);
    return 0;
}


#include <iostream>
using namespace std;
int bol[1000001];
char a[1000001];
char b[1000001];
int ok,n,m;
int mt(int ,int);
int main()
{
    int i=0,j,t;
    int fs=0,fe=1;
    int MIN=1000001;
    while(fe<=1000000)
    {
         t=fe;
         fe=fs+fe;
         fs=t;
         bol[i++]=fe;
    }
    cin>>n>>m;
    n--;
    if((n+1)%2)
       a[n+1]='B';
    else
       a[n+1]='T';
    int l=n;
    for(i=bol[n-1];i>m/2;i--)
    {
       int min=0;
       n=l;
       ok=0;
       if(m>i)
        mt(m,i);
       if(ok)
       {
       for(j=0;j<=l;j++)
         if(j%2)
         {
            if(a[j]!='B')
              min++;
         }
         else
         {
            if(a[j]!='T')
              min++;
         }
       if(min<MIN)
       {
         for(j=0;j<=l;j++)
          b[j]=a[j];
         MIN=min;
       }
       }
    }
    if(b[0]!='\0')
    {
       cout<<MIN<<endl;
       for(i=0;i<=l;i++)
          cout<<b[i];
    }
    else
       cout<<"IMPOSSIBLE";
   cout<<endl;
   return 0;
}
int mt(int end,int start)
{
    int i;
    if(end==start)
      return 0;
    if(end<start)
     {
       a[n]=a[n+1];
       int t=start;
       start=end;
       end=t;
     }
    else
    {
         if(a[n+1]=='T')
           a[n]='B';
         else
           a[n]='T';
    }
    if(bol[n]==end&&bol[n-1]==start)
    {
      for(i=0;i<n;i++)
        if(i%2)
          a[i]='B';
        else
          a[i]='T';
      ok=1;
      return 0;
    }
    if(n==1)
     return 0;
    n--;
    int t=start;
    start=end-t;
    end=t;
    mt(end,start);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define FREP(b) for(int i=0;i<b;i++)
#define REP(a,b,c) for(int a=b;a<c;a++)
#define asd(x) cout << "Here for " << #x << " :" <<x << endl;
#define asdf(x, y)  cout << "Here FOR " << #x << " :" << x << " " << #y  << " :" << y << endl;
typedef pair<int,int> ii;
typedef long long LL;
char ans[1000009];
string ANS;
int mini = INT_MAX;
void check(int top, int bottom, int ops){
    // Ok...
    int a = top, b = bottom;
    for(int i = ops-1; i > 0; i--){
        if(top > bottom) top -= bottom, ans[i] = 'T';
        else bottom -= top, ans[i] = 'B';
        if(bottom <= 0 || top <= 0) return;

    }
    if(top != bottom || top != 1) return;
    ans[0] = 'T';
//    asdf(a, b);
  //  asd(ans);
    int res = 0;
    for(int i = 0; i < ops-1; i++){
        if(ans[i] == ans[i+1]) res++;
    }
    //asdf(res, ans);
    if(res < mini) mini = res, ANS = string(ans);
}
int main()
{
    int n,r;
    cin >> n >> r;
    for(int i = 0; i <= r; i++){
        check(r, i, n);
        check(i, r, n);
    }
    if(mini == INT_MAX){
        cout << "IMPOSSIBLE" << endl;
        return 0;
    }
    cout << mini << endl;
    cout << ANS << endl;
    return 0;
}


#include<cstdio>
#define inf 200000000
using namespace std;
int n,r,tot,ans,sum,a[1000005],tt;
void gcd(int x,int y)
{
	if (y!=0)
	{
		tot+=x/y; if(x/y>1)sum+=(x/y)-1;
		if (x%y==0&&x/y>1) sum--;
	}
	if (y==0)return; else gcd(y,x%y);
}
void gcd2(int x,int y)
{
	if (y!=0&&x/y!=0)a[tot++]=x/y;
	if (y==0)return; else gcd2(y,x%y);
}

int main()
{
	scanf("%d%d",&n,&r);
	if (n>r) {printf("IMPOSSIBLE");return 0;}
	ans=inf;
	for (int i=1;i<r;i++)
	{
		tot=0; sum=0;
		gcd(r,i);
		if (tot==n&&sum<ans)
		{
			ans=sum; tot=0; gcd2(i,r); tt=tot;
		}
	}
	if (ans==inf){printf("IMPOSSIBLE");return 0;}
	printf("%d\n",ans);
	int pos=1;
	a[tt-1]--; printf("T");
	for (int i=tt-1;i>=0;i--)
	{
		for (int j=0;j<a[i];j++)
			if (pos==0)
				printf("T"); else printf("B");
		pos=1-pos;
	}
	return 0;
}


#include<cstdio>
#define inf 200000000
using namespace std;
int n,r,tot,ans,sum,flag,a[1000005],tt;
void gcd(int x,int y)
{
	if (y!=0)
	{
		tot+=x/y; if(x/y>1)sum+=(x/y)-1;
		if (x%y==0&&x/y>1) sum--;
	}
	if (x%y==0&&y==1) flag=1;
	if (y==0)return; else gcd(y,x%y);
}
void gcd2(int x,int y)
{
	if (y!=0&&x/y!=0)a[tot++]=x/y;
	if (y==0)return; else gcd2(y,x%y);
}

int main()
{
	scanf("%d%d",&n,&r);
	ans=inf;
	for (int i=0;i<r;i++)
	{
		tot=0; sum=0; flag=0;
		gcd(r,i);
		if (tot==n&&sum<ans&&flag)
		{
			ans=sum; tot=0; gcd2(i,r); tt=tot;
		}
	}
	if (ans==inf){printf("IMPOSSIBLE");return 0;}
	printf("%d\n",ans);
	int pos=1;
	a[tt-1]--; printf("T");
	for (int i=tt-1;i>=0;i--)
	{
		for (int j=0;j<a[i];j++)
			if (pos==0)
				printf("T"); else printf("B");
		pos=1-pos;
	}
	return 0;
}


#include<cstdio>
#define inf 200000000
using namespace std;
int n,r,tot,ans,sum,a[1000005],tt;
void gcd(int x,int y)
{
	if (y!=0)
	{
		tot+=x/y; if(x/y>1)sum+=(x/y)-1;
		if (x%y==0&&x/y>1) sum--;
	}
	if (y==0)return; else gcd(y,x%y);
}
void gcd2(int x,int y)
{
	if (y!=0&&x/y!=0)a[tot++]=x/y;
	if (y==0)return; else gcd2(y,x%y);
}

int main()
{
	scanf("%d%d",&n,&r);
	ans=inf;
	for (int i=1;i<r;i++)
	{
		tot=0; sum=0;
		gcd(r,i);
		if (tot==n&&sum<ans)
		{
			ans=sum; tot=0; gcd2(i,r); tt=tot;
		}
	}
	if (ans==inf){printf("IMPOSSIBLE");return 0;}
	printf("%d\n",ans);
	int pos=1;
	a[tt-1]--; printf("T");
	for (int i=tt-1;i>=0;i--)
	{
		for (int j=0;j<a[i];j++)
			if (pos==0)
				printf("T"); else printf("B");
		pos=1-pos;
	}
	return 0;
}


#include<cstdio>
#define inf 200000000
using namespace std;
int n,r,tot,ans,sum,flag,a[1000005],tt;
void gcd(int x,int y)
{
	if (y!=0)
	{
		tot+=x/y; if(x/y>1)sum+=(x/y)-1;
		if (x%y==0&&x/y>1) sum--;
	}
	if (x%y==0&&y==1) flag=1;
	if (y==0)return; else gcd(y,x%y);
}
void gcd2(int x,int y)
{
	if (y!=0&&x/y!=0)a[tot++]=x/y;
	if (y==0)return; else gcd2(y,x%y);
}

int main()
{
	scanf("%d%d",&n,&r);
	ans=inf;
	for (int i=0;i<r;i++)
	{
		tot=0; sum=0; flag=0;
		gcd(r,i);
		if (tot==n&&sum<ans&&flag)
		{
			ans=sum; tot=0; gcd2(i,r); tt=tot;
		}
	}
	if (n==1&&r==1)printf("0\nT");
	if (ans==inf){printf("IMPOSSIBLE");return 0;}
	printf("%d\n",ans);
	int pos=1;
	a[tt-1]--; printf("T");
	for (int i=tt-1;i>=0;i--)
	{
		for (int j=0;j<a[i];j++)
			if (pos==0)
				printf("T"); else printf("B");
		pos=1-pos;
	}
	return 0;
}


#include<cstdio>
#define inf 200000000
using namespace std;
int n,r,tot,ans,sum,flag,a[1000005],tt;
void gcd(int x,int y)
{
	if (y!=0)
	{
		tot+=x/y; if(x/y>1)sum+=(x/y)-1;
		if (x%y==0&&x/y>1) sum--;
	}
	if (x%y==0&&y==1) flag=1;
	if (y==0)return; else gcd(y,x%y);
}
void gcd2(int x,int y)
{
	if (y!=0&&x/y!=0)a[tot++]=x/y;
	if (y==0)return; else gcd2(y,x%y);
}

int main()
{
	scanf("%d%d",&n,&r);
	ans=inf;
	for (int i=0;i<r;i++)
	{
		tot=0; sum=0; flag=0;
		gcd(r,i);
		if (tot==n&&sum<ans&&flag)
		{
			ans=sum; tot=0; gcd2(i,r); tt=tot;
		}
	}
	if (n==1&&r==1){printf("0\nT");return 0;}
	if (ans==inf){printf("IMPOSSIBLE");return 0;}
	printf("%d\n",ans);
	int pos=1;
	a[tt-1]--; printf("T");
	for (int i=tt-1;i>=0;i--)
	{
		for (int j=0;j<a[i];j++)
			if (pos==0)
				printf("T"); else printf("B");
		pos=1-pos;
	}
	return 0;
}


#include<cstdio>
#define inf 200000000
using namespace std;
int n,r,tot,ans,sum,a[1000005];
void gcd(int x,int y)
{
	if (y!=0){tot+=x/y; sum+=(x/y)-1;}
	if (y==0)return; else gcd(y,x%y);
}
void gcd2(int x,int y)
{
	if (y!=0&&x/y!=0)a[tot++]=x/y;
	if (y==0)return; else gcd2(y,x%y);
}

int main()
{
	scanf("%d%d",&n,&r);
	if (n>r) {printf("IMPOSSIBLE");return 0;}
	ans=inf;
	for (int i=1;i<r;i++)
	{
		tot=0; sum=0;
		gcd(i,r);
		if (tot==n&&sum<ans)
		{
			ans=sum; tot=0; gcd2(i,r);
		}
	}
	printf("%d\n",ans);
	int pos=0;
	for (int i=0;i<tot;i++)
	{
		for (int j=0;j<a[i];j++)
			if (pos==0)
				printf("T"); else printf("B");
		pos=1-pos;
	}
	return 0;
}


#include<cstdio>
#define inf 200000000
using namespace std;
int n,r,tot,ans,sum,a[1000005];
void gcd(int x,int y)
{
	if (y!=0){tot+=x/y; sum+=(x/y)-1;}
	if (y==0)return; else gcd(y,x%y);
}
void gcd2(int x,int y)
{
	if (y!=0&&x/y!=0)a[tot++]=x/y;
	if (y==0)return; else gcd2(y,x%y);
}

int main()
{
	scanf("%d%d",&n,&r);
	if (n>r) {printf("IMPOSSIBLE");return 0;}
	ans=inf;
	for (int i=1;i<r;i++)
	{
		tot=0; sum=0;
		gcd(i,r);
		if (tot==n&&sum<ans)
		{
			ans=sum; tot=0; gcd2(i,r);
		}
	}
	if (ans==inf){printf("IMPOSSIBLE");return 0;}
	printf("%d\n",ans);
	int pos=0;
	for (int i=tot-1;i>=0;i--)
		if (a[i]!=0) {a[i]--;break;}
	for (int i=0;i<tot;i++)
	{
		for (int j=0;j<a[i];j++)
			if (pos==0)
				printf("T"); else printf("B");
		pos=1-pos;
	}
	if (n&1)printf("T"); else printf("B");
	return 0;
}


#include<cstdio>
#define inf 200000000
using namespace std;
int n,r,tot,ans,sum,flag,a[1000005],tt;
void gcd(int x,int y)
{
	if (y!=0)
	{
		tot+=x/y; if(x/y>1)sum+=(x/y)-1;
		if (x%y==0&&x/y>1) sum--;
	}
	if (x%y==0&&y==1) flag=1;
	if (y==0)return; else gcd(y,x%y);
}
void gcd2(int x,int y)
{
	if (y!=0&&x/y!=0)a[tot++]=x/y;
	if (y==0)return; else gcd2(y,x%y);
}

int main()
{
	scanf("%d%d",&n,&r);
	ans=inf;
	for (int i=0;i<r;i++)
	{
		tot=0; sum=0; flag=0;
		gcd(r,i);
		if (tot==n&&sum<ans&&flag)
		{
			ans=sum; tot=0; gcd2(i,r); tt=tot;
		}
	}
	if (n==1&&r==0)printf("0\nT");
	if (ans==inf){printf("IMPOSSIBLE");return 0;}
	printf("%d\n",ans);
	int pos=1;
	a[tt-1]--; printf("T");
	for (int i=tt-1;i>=0;i--)
	{
		for (int j=0;j<a[i];j++)
			if (pos==0)
				printf("T"); else printf("B");
		pos=1-pos;
	}
	return 0;
}


#include<cstdio>
#define inf 200000000
using namespace std;
int n,r,tot,ans,sum,a[1000005];
void gcd(int x,int y)
{
	if (y!=0){tot+=x/y; sum+=(x/y)-1;}
	if (y==0)return; else gcd(y,x%y);
}
void gcd2(int x,int y)
{
	if (y!=0&&x/y!=0)a[tot++]=x/y;
	if (y==0)return; else gcd2(y,x%y);
}

int main()
{
	scanf("%d%d",&n,&r);
	if (n>r) {printf("IMPOSSIBLE");return 0;}
	ans=inf;
	for (int i=1;i<r;i++)
	{
		tot=0; sum=0;
		gcd(i,r);
		if (tot==n&&sum<ans)
		{
			ans=sum; tot=0; gcd2(i,r);
		}
	}
	printf("%d\n",ans);
	int pos=0;
	for (int i=tot-1;i>=0;i--)
		if (a[i]!=0) {a[i]--;break;}
	for (int i=0;i<tot;i++)
	{
		for (int j=0;j<a[i];j++)
			if (pos==0)
				printf("T"); else printf("B");
		pos=1-pos;
	}
	printf("B");
	return 0;
}


#include<cstdio>
#define inf 200000000
using namespace std;
int n,r,tot,ans,sum,flag,a[1000005],tt;
void gcd(int x,int y)
{
	if (y!=0)
	{
		tot+=x/y; if(x/y>1)sum+=(x/y)-1;
		if (x%y==0&&x/y>1) sum--;
	}
	if (x%y==0&&y==1) flag=1;
	if (y==0)return; else gcd(y,x%y);
}
void gcd2(int x,int y)
{
	if (y!=0&&x/y!=0)a[tot++]=x/y;
	if (y==0)return; else gcd2(y,x%y);
}

int main()
{
	scanf("%d%d",&n,&r);
	ans=inf;
	for (int i=1;i<r;i++)
	{
		tot=0; sum=0; flag=0;
		gcd(r,i);
		if (tot==n&&sum<ans&&flag)
		{
			ans=sum; tot=0; gcd2(i,r); tt=tot;
		}
	}
	if (ans==inf){printf("IMPOSSIBLE");return 0;}
	printf("%d\n",ans);
	int pos=1;
	a[tt-1]--; printf("T");
	for (int i=tt-1;i>=0;i--)
	{
		for (int j=0;j<a[i];j++)
			if (pos==0)
				printf("T"); else printf("B");
		pos=1-pos;
	}
	return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cassert>
#include <sstream>
#include <cmath>
#include <queue>
using namespace std;

#define SIZE(x) ((int)s.size())
#define PB push_back

int n;
int k;
int ansLen = 1 << 29;
char ans[111111];
char a[111111];

void go(int x, int y)
{
    int len = 0;
    while(x != y)
    {
        if (x > y)
        {
            a[len++] = 'T';
            x -= y;
        }
        else
        {
            a[len++] = 'B';
            y -= x;
        }
    }
    if (x > 1) return;
    a[len++] = 'T';
    if (len != n) return;

    reverse(a, a+len);
    int cnt = 0;
    for (int i=1; i<len; i++)
        if (a[i-1] == a[i]) cnt++;
    if (cnt < ansLen)
    {
        ansLen = cnt;
        for (int i=0; i<n; i++) ans[i] = a[i];
    }
}
int main(void)
{
    cin >> n >> k;

    for (int i=1; i<=k; i++)
    {
        go(i, k);
        go(k, i);
    }
    if (ansLen >= (1 << 29)) cout << "IMPOSSIBLE\n";
    else
    {
        cout << ansLen << '\n';
        for (int i=0; i<n; i++)
            cout << ans[i];
        cout << "\n";
    }

    return 0;
}


#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cassert>
#include <sstream>
#include <cmath>
#include <queue>
using namespace std;

#define SIZE(x) ((int)s.size())
#define PB push_back

int n;
int k;
int ansLen = 1 << 29;
char ans[1111111];
char a[1111111];

void go(int x, int y)
{
    int len = 0;
    while(x != y)
    {
        if (x > y)
        {
            a[len++] = 'T';
            x -= y;
        }
        else
        {
            a[len++] = 'B';
            y -= x;
        }
    }
    if (x > 1) return;
    a[len++] = 'T';
    if (len != n) return;

    reverse(a, a+len);
    int cnt = 0;
    for (int i=1; i<len; i++)
        if (a[i-1] == a[i]) cnt++;
    if (cnt < ansLen)
    {
        ansLen = cnt;
        for (int i=0; i<n; i++) ans[i] = a[i];
    }
}
int main(void)
{
    cin >> n >> k;

    for (int i=1; i<=k; i++)
    {
        go(i, k);
        go(k, i);
    }
    if (ansLen >= (1 << 29)) cout << "IMPOSSIBLE\n";
    else
    {
        cout << ansLen << '\n';
        for (int i=0; i<n; i++)
            cout << ans[i];
        cout << "\n";
    }

    return 0;
}


#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int test(int a,int b){
    int n=a;
    int total=0;
    int ne;
    while(a!=1&&b!=1){
        ne=a%b;
        total+=(a-ne)/b;
        a=ne;
        swap(a,b);
    }
    total+=a-1;
    return total;
}
vector<int>res;
int rest;
char at[]={'T','B'};
void get(int a,int b,int n){
    int total=0;
    int ne;
    int cnt;
    vector<int>cur;
    cur.reserve(n);
    int i;
    if(a<b)swap(a,b);
    cur.push_back(0);
    while(a!=1&&b!=1){
        ne=a%b;
        cnt=(a-ne)/b;
        for(i=0;i<cnt;++i)cur.push_back(i==cnt-1);
        a=ne;
        swap(a,b);
    }
    for(i=1;i<a;++i)cur.push_back(i==a-1);
    for(i=1;i<n-1;++i){
        if(!cur[i])++total;
    }
    cur[0]=1;
    if(total<rest){
        res=cur;
        rest=total;
    }
    return;
}
int main(){
    int n,f;
    scanf("%d%d",&n,&f);
    rest=n;
    int i;
    for(i=f/2+1;i<f;++i){
        if(gcd(i,f)==1&&test(f-i,i)==n-2)get(f-i,i,n);
    }
    int cur=0;
    if(res.size()){
        printf("%d\n",rest);
        putchar('T');
        for(i=res.size()-1;i>=0;--i)putchar(at[cur^=res[i]]);
        putchar('\n');
    }else puts("IMPOSSIBLE");
    return 0;
}


#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int test(int a,int b,int n){
    int step=0;
    int total=0;
    int ne;
    int cur;
    if(a<b)swap(a,b);
    while(a!=1&&b!=1){
        ne=a%b;
        cur=(a-ne)/b;
        step+=cur;
        total+=cur-1;
        a=ne;
        swap(a,b);
    }
    step+=a-1;
    total+=a-2;
    if(step!=n)return 0x7fffffff;
    return total;
}
vector<int>res;
int rest;
char at[]={'T','B'};
void get(int a,int b,int n){
    const int ca=a,cb=b;
    int total=0;
    int ne;
    int cnt;
    res.clear();
    int i;
    if(a<b)swap(a,b);
    res.push_back(1);
    while(a!=1&&b!=1){
        ne=a%b;
        cnt=(a-ne)/b;
        for(i=0;i<cnt;++i)res.push_back(i==cnt-1);
        a=ne;
        swap(a,b);
    }
    for(i=1;i<a;++i)res.push_back(i==a-1);
    return;
}
int main(){
    int n,f;
    scanf("%d%d",&n,&f);
    res.reserve(n);
    if(n==f&&n==1){
        printf("0\nT\n");
        return 0;
    }
    rest=n;
    int i;
    int ret;
    if(n<=f){
        for(i=1;(i<<1)<f;++i){
            if(gcd(i,f-i)==1){
                ret=test(i,f-i,n-2);
                if(ret<rest){
                    rest=ret;
                    get(f-i,i,n);
                }
            }
        }
    }
    int cur=0;
    if(res.size()){
        printf("%d\n",rest);
        putchar('T');
        for(i=res.size()-1;i>=0;--i)putchar(at[cur^=res[i]]);
        putchar('\n');
    }else puts("IMPOSSIBLE");
    return 0;
}


#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
#define INF 0x7fffffff
int test(int a,int b,int n){
    int step=0;
    int total=0;
    int ne;
    if(a<b)swap(a,b);
    while(a!=1&&b!=1){
        ne=a%b;
        if(!ne)return INF;
        step+=(a-ne)/b;
        ++total;
        a=ne;
        swap(a,b);
    }
    step+=a-1;
    if(step!=n)return INF;
    return n-total-1;
}
void get(int a,int b,vector<bool>&res){
    const int ca=a,cb=b;
    int total=0;
    int ne;
    int cnt;
    res.clear();
    int i;
    if(a<b)swap(a,b);
    res.push_back(1);
    while(a!=1&&b!=1){
        ne=a%b;
        cnt=(a-ne)/b;
        for(i=0;i<cnt;++i)res.push_back(i==cnt-1);
        a=ne;
        swap(a,b);
    }
    for(i=1;i<a;++i)res.push_back(i==a-1);
    res.push_back(0);
    return;
}
int main(){
    int n,f;
    char at[]={'T','B'};
    int resmin,ra;
    int i;
    while(~scanf("%d%d",&n,&f)){
        if(n==f&&n==1)printf("0\nT\n");
        else{
            if(n>f){
                resmin=n;
            }else if(n==f){
                resmin=max(n-3,0);
                ra=1;
            }else{
                resmin=n;
                int ret;
                if(n<=f){
                    for(i=1;(i<<1)<f;++i){
                        ret=test(i,f-i,n-2);
                        if(ret<resmin){
                            resmin=ret;
                            ra=i;
                        }
                    }
                }
            }
            vector<bool>res(n);
            int cur=0;
            if(resmin<n){
                get(ra,f-ra,res);
                printf("%d\n",resmin);
                for(i=res.size()-1;i>=0;--i)putchar(at[cur^=(int)res[i]]);
                putchar('\n');
            }else puts("IMPOSSIBLE");
        }
    }
    return 0;
}


#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
#define INF 0x7fffffff
int test(int a,int b,int n){
    int step=0;
    int total=0;
    int ne;
    if(a<b)swap(a,b);
    while(a!=1&&b!=1){
        ne=a%b;
        if(!ne)return INF;
        step+=(a-ne)/b;
        ++total;
        a=ne;
        swap(a,b);
    }
    step+=a-1;
    if(step!=n)return INF;
    return n-total-1;
}
void get(int a,int b,vector<int>&res){
    const int ca=a,cb=b;
    int total=0;
    int ne;
    int cnt;
    res.clear();
    int i;
    if(a<b)swap(a,b);
    res.push_back(1);
    while(a!=1&&b!=1){
        ne=a%b;
        cnt=(a-ne)/b;
        for(i=0;i<cnt;++i)res.push_back(i==cnt-1);
        a=ne;
        swap(a,b);
    }
    for(i=1;i<a;++i)res.push_back(i==a-1);
    res.push_back(0);
    return;
}
int main(){
    int n,f;
    while(~scanf("%d%d",&n,&f)){
        if(n==f&&n==1){
            printf("0\nT\n");
            continue;
        }
        int resmin=n;
        int i;
        int ret;
        int ra;
        if(n<=f){
            for(i=1;(i<<1)<f;++i){
                ret=test(i,f-i,n-2);
                if(ret<resmin){
                    resmin=ret;
                    ra=i;
                }
            }
        }
        char at[]={'T','B'};
        vector<int>res(n);
        int cur=0;
        if(resmin<n){
            get(ra,f-ra,res);
            printf("%d\n",resmin);
            for(i=res.size()-1;i>=0;--i)putchar(at[cur^=res[i]]);
            putchar('\n');
        }else puts("IMPOSSIBLE");
    }
    return 0;
}


#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
#define INF 0x7fffffff
int test(int a,int b,int n){
    int step=0;
    int total=0;
    int ne;
    int cur;
    if(a<b)swap(a,b);
    while(a!=1&&b!=1){
        ne=a%b;
        if(!ne)return INF;
        cur=(a-ne)/b;
        step+=cur;
        ++total;
        a=ne;
        swap(a,b);
    }
    step+=a-1;
    if(step!=n)return INF;
    return n-total-1;
}
vector<int>res;
char at[]={'T','B'};
void get(int a,int b){
    const int ca=a,cb=b;
    int total=0;
    int ne;
    int cnt;
    res.clear();
    int i;
    if(a<b)swap(a,b);
    res.push_back(1);
    while(a!=1&&b!=1){
        ne=a%b;
        cnt=(a-ne)/b;
        for(i=0;i<cnt;++i)res.push_back(i==cnt-1);
        a=ne;
        swap(a,b);
    }
    for(i=1;i<a;++i)res.push_back(i==a-1);
    return;
}
int main(){
    int n,f;
    scanf("%d%d",&n,&f);
    res.reserve(n);
    if(n==f&&n==1){
        printf("0\nT\n");
        return 0;
    }
    int resmin=n;
    int i;
    int ret;
    int ra;
    if(n<=f){
        for(i=1;(i<<1)<f;++i){
            ret=test(i,f-i,n-2);
            if(ret<resmin){
                resmin=ret;
                ra=f-i;
            }
        }
    }
    int cur=0;
    if(resmin<n){
        get(ra,n-ra);
        printf("%d\n",resmin);
        putchar('T');
        for(i=res.size()-1;i>=0;--i)putchar(at[cur^=res[i]]);
        putchar('\n');
    }else puts("IMPOSSIBLE");
    return 0;
}


#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int test(int a,int b){
    int n=a;
    int total=0;
    int ne;
    if(a<b)swap(a,b);
    while(a!=1&&b!=1){
        ne=a%b;
        total+=(a-ne)/b;
        a=ne;
        swap(a,b);
    }
    total+=a-1;
    return total;
}
vector<int>res;
int rest;
char at[]={'T','B'};
void get(int a,int b,int n){
    int total=0;
    int ne;
    int cnt;
    vector<int>cur;
    cur.reserve(n);
    int i;
    if(a<b)swap(a,b);
    cur.push_back(0);
    while(a!=1&&b!=1){
        ne=a%b;
        cnt=(a-ne)/b;
        for(i=0;i<cnt;++i)cur.push_back(i==cnt-1);
        a=ne;
        swap(a,b);
    }
    for(i=1;i<a;++i)cur.push_back(i==a-1);
    for(i=1;i<n-1;++i){
        if(!cur[i])++total;
    }
    cur[0]=1;
    if(total<rest){
        res=cur;
        rest=total;
    }
    return;
}
int main(){
    int n,f;
    scanf("%d%d",&n,&f);
    if(n==f&&n==1){
        printf("0\nT\n");
        return 0;
    }
    rest=n;
    int i;
    if(n<=f){
        for(i=1;(i<<1)<f;++i){
            if(gcd(i,f-i)==1&&test(i,f-i)==n-2){
                get(f-i,i,n);
            }
        }
    }
    int cur=0;
    if(res.size()){
        printf("%d\n",rest);
        putchar('T');
        for(i=res.size()-1;i>=0;--i)putchar(at[cur^=res[i]]);
        putchar('\n');
    }else puts("IMPOSSIBLE");
    return 0;
}


#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int test(int a,int b,int n){
    int step=0;
    int total=0;
    int ne;
    int cur;
    if(a<b)swap(a,b);
    while(a!=1&&b!=1){
        ne=a%b;
        cur=(a-ne)/b;
        step+=cur;
        ++total;
        a=ne;
        swap(a,b);
    }
    step+=a-1;
    if(step!=n)return 0x7fffffff;
    return n-total-1;
}
vector<int>res;
int rest;
char at[]={'T','B'};
void get(int a,int b,int n){
    const int ca=a,cb=b;
    int total=0;
    int ne;
    int cnt;
    res.clear();
    int i;
    if(a<b)swap(a,b);
    res.push_back(1);
    while(a!=1&&b!=1){
        ne=a%b;
        cnt=(a-ne)/b;
        for(i=0;i<cnt;++i)res.push_back(i==cnt-1);
        a=ne;
        swap(a,b);
    }
    for(i=1;i<a;++i)res.push_back(i==a-1);
    return;
}
int main(){
    int n,f;
    scanf("%d%d",&n,&f);
    res.reserve(n);
    if(n==f&&n==1){
        printf("0\nT\n");
        return 0;
    }
    rest=n;
    int i;
    int ret;
    if(n<=f){
        for(i=1;(i<<1)<f;++i){
            if(gcd(i,f-i)==1){
                ret=test(i,f-i,n-2);
                if(ret<rest){
                    rest=ret;
                    get(f-i,i,n);
                }
            }
        }
    }
    int cur=0;
    if(res.size()){
        printf("%d\n",rest);
        putchar('T');
        for(i=res.size()-1;i>=0;--i)putchar(at[cur^=res[i]]);
        putchar('\n');
    }else puts("IMPOSSIBLE");
    return 0;
}


#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
#define INF 0x7fffffff
int test(int a,int b,int n){
    int step=0;
    int total=0;
    int ne;
    int cur;
    if(a<b)swap(a,b);
    while(a!=1&&b!=1){
        ne=a%b;
        if(!ne)return INF;
        cur=(a-ne)/b;
        step+=cur;
        ++total;
        a=ne;
        swap(a,b);
    }
    step+=a-1;
    if(step!=n)return INF;
    return n-total-1;
}
vector<int>res;
int rest;
char at[]={'T','B'};
void get(int a,int b,int n){
    const int ca=a,cb=b;
    int total=0;
    int ne;
    int cnt;
    res.clear();
    int i;
    if(a<b)swap(a,b);
    res.push_back(1);
    while(a!=1&&b!=1){
        ne=a%b;
        cnt=(a-ne)/b;
        for(i=0;i<cnt;++i)res.push_back(i==cnt-1);
        a=ne;
        swap(a,b);
    }
    for(i=1;i<a;++i)res.push_back(i==a-1);
    return;
}
int main(){
    int n,f;
    scanf("%d%d",&n,&f);
    res.reserve(n);
    if(n==f&&n==1){
        printf("0\nT\n");
        return 0;
    }
    rest=n;
    int i;
    int ret;
    if(n<=f){
        for(i=1;(i<<1)<f;++i){
            ret=test(i,f-i,n-2);
            if(ret<rest){
                rest=ret;
                get(f-i,i,n);
            }
        }
    }
    int cur=0;
    if(res.size()){
        printf("%d\n",rest);
        putchar('T');
        for(i=res.size()-1;i>=0;--i)putchar(at[cur^=res[i]]);
        putchar('\n');
    }else puts("IMPOSSIBLE");
    return 0;
}


#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int test(int a,int b){
    int n=a;
    int total=0;
    int ne;
    if(a<b)swap(a,b);
    while(a!=1&&b!=1){
        ne=a%b;
        total+=(a-ne)/b;
        a=ne;
        swap(a,b);
    }
    total+=a-1;
    return total;
}
vector<int>res;
int rest;
char at[]={'T','B'};
void get(int a,int b,int n){
    int total=0;
    int ne;
    int cnt;
    vector<int>cur;
    cur.reserve(n);
    int i;
    if(a<b)swap(a,b);
    cur.push_back(0);
    while(a!=1&&b!=1){
        ne=a%b;
        cnt=(a-ne)/b;
        for(i=0;i<cnt;++i)cur.push_back(i==cnt-1);
        a=ne;
        swap(a,b);
    }
    for(i=1;i<a;++i)cur.push_back(i==a-1);
    for(i=1;i<n-1;++i){
        if(!cur[i])++total;
    }
    cur[0]=1;
    if(total<rest){
        res=cur;
        rest=total;
    }
    return;
}
int main(){
    int n,f;
    scanf("%d%d",&n,&f);
    if(n==f&&n==1){
        printf("0\nT\n");
        return 0;
    }
    rest=n;
    int i;
    if(n<=f){
        for(i=min(f/2+1,f-1);i<=f;++i){
            if(gcd(i,f)==1&&test(f-i,i)==n-2){
                get(f-i,i,n);
            }
        }
    }
    int cur=0;
    if(res.size()){
        printf("%d\n",rest);
        putchar('T');
        for(i=res.size()-1;i>=0;--i)putchar(at[cur^=res[i]]);
        putchar('\n');
    }else puts("IMPOSSIBLE");
    return 0;
}


#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int test(int a,int b){
    int n=a;
    int total=0;
    int ne;
    if(a<b)swap(a,b);
    while(a!=1&&b!=1){
        ne=a%b;
        total+=(a-ne)/b;
        a=ne;
        swap(a,b);
    }
    total+=a-1;
    return total;
}
vector<int>res;
int rest;
char at[]={'T','B'};
void get(int a,int b,int n){
    int total=0;
    int ne;
    int cnt;
    vector<int>cur;
    cur.reserve(n);
    int i;
    if(a<b)swap(a,b);
    cur.push_back(0);
    while(a!=1&&b!=1){
        ne=a%b;
        cnt=(a-ne)/b;
        for(i=0;i<cnt;++i)cur.push_back(i==cnt-1);
        a=ne;
        swap(a,b);
    }
    for(i=1;i<a;++i)cur.push_back(i==a-1);
    for(i=1;i<n-1;++i){
        if(!cur[i])++total;
    }
    cur[0]=1;
    if(total<rest){
        res=cur;
        rest=total;
    }
    return;
}
int main(){
    int n,f;
    scanf("%d%d",&n,&f);
    if(n==f&&n==1){
        printf("0\nT\n");
        return 0;
    }
    rest=n;
    int i;
    for(i=min(f/2+1,f-1);i<=f;++i){
        if(gcd(i,f)==1&&test(f-i,i)==n-2){
            get(f-i,i,n);
        }
    }
    int cur=0;
    if(res.size()){
        printf("%d\n",rest);
        putchar('T');
        for(i=res.size()-1;i>=0;--i)putchar(at[cur^=res[i]]);
        putchar('\n');
    }else puts("IMPOSSIBLE");
    return 0;
}


#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int test(int a,int b){
    int n=a;
    int total=0;
    int ne;
    while(a!=1&&b!=1){
        ne=a%b;
        total+=(a-ne)/b;
        a=ne;
        swap(a,b);
    }
    total+=a-1;
    return total;
}
vector<int>res;
int rest;
char at[]={'T','B'};
void get(int a,int b,int n){
    int total=0;
    int ne;
    int cnt;
    vector<int>cur;
    cur.reserve(n);
    int i;
    if(a<b)swap(a,b);
    cur.push_back(0);
    while(a!=1&&b!=1){
        ne=a%b;
        cnt=(a-ne)/b;
        for(i=0;i<cnt;++i)cur.push_back(i==cnt-1);
        a=ne;
        swap(a,b);
    }
    for(i=1;i<a;++i)cur.push_back(i==a-1);
    for(i=1;i<n-1;++i){
        if(!cur[i])++total;
    }
    if(total>n-2-total){
        total=n-2-total;
    }
    cur[0]=1;
    cur.push_back(0);
    if(total<rest){
        res=cur;
        rest=total;
    }
    return;
}
int main(){
    int n,f;
    scanf("%d%d",&n,&f);
    rest=n;
    int i;
    for(i=f/2+1;i<f;++i){
        if(gcd(i,f)==1&&test(f-i,i)==n-2)get(f-i,i,n);
    }
    int cur=0;
    if(res.size()){
        printf("%d\n",rest);
        for(i=res.size()-1;i>=0;--i)putchar(at[cur^=res[i]]);
        putchar('\n');
    }else puts("IMPOSSIBLE");
    return 0;
}


#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
#define INF 0x7fffffff
int test(int a,int b,int n){
    int step=0;
    int total=0;
    int ne;
    int cur;
    if(a<b)swap(a,b);
    while(a!=1&&b!=1){
        ne=a%b;
        if(!ne)return INF;
        cur=(a-ne)/b;
        step+=cur;
        ++total;
        a=ne;
        swap(a,b);
    }
    step+=a-1;
    if(step!=n)return INF;
    return n-total-1;
}
vector<int>res;
char at[]={'T','B'};
void get(int a,int b){
    const int ca=a,cb=b;
    int total=0;
    int ne;
    int cnt;
    res.clear();
    int i;
    if(a<b)swap(a,b);
    res.push_back(1);
    while(a!=1&&b!=1){
        ne=a%b;
        cnt=(a-ne)/b;
        for(i=0;i<cnt;++i)res.push_back(i==cnt-1);
        a=ne;
        swap(a,b);
    }
    for(i=1;i<a;++i)res.push_back(i==a-1);
    return;
}
int main(){
    int n,f;
    scanf("%d%d",&n,&f);
    res.reserve(n);
    if(n==f&&n==1){
        printf("0\nT\n");
        return 0;
    }
    int resmin=n;
    int i;
    int ret;
    int ra;
    if(n<=f){
        for(i=1;(i<<1)<f;++i){
            ret=test(i,f-i,n-2);
            if(ret<resmin){
                resmin=ret;
                ra=i;
            }
        }
    }
    int cur=0;
    if(resmin<n){
        get(ra,f-ra);
        printf("%d\n",resmin);
        putchar('T');
        for(i=res.size()-1;i>=0;--i)putchar(at[cur^=res[i]]);
        putchar('\n');
    }else puts("IMPOSSIBLE");
    return 0;
}


#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
#define INF 0x7fffffff
int test(int a,int b,int n){
    int step=0;
    int total=0;
    int ne;
    if(a<b)swap(a,b);
    while(a!=1&&b!=1){
        ne=a%b;
        if(!ne)return INF;
        step+=(a-ne)/b;
        ++total;
        a=ne;
        swap(a,b);
    }
    step+=a-1;
    if(step!=n)return INF;
    return n-total-1;
}
void get(int a,int b,vector<int>&res){
    const int ca=a,cb=b;
    int total=0;
    int ne;
    int cnt;
    res.clear();
    int i;
    if(a<b)swap(a,b);
    res.push_back(1);
    while(a!=1&&b!=1){
        ne=a%b;
        cnt=(a-ne)/b;
        for(i=0;i<cnt;++i)res.push_back(i==cnt-1);
        a=ne;
        swap(a,b);
    }
    for(i=1;i<a;++i)res.push_back(i==a-1);
    res.push_back(0);
    return;
}
int main(){
    int n,f;
    char at[]={'T','B'};
    int resmin,ra;
    int i;
    while(~scanf("%d%d",&n,&f)){
        if(n==f&&n==1)printf("0\nT\n");
        else{
            if(n>f){
                resmin=n;
            }else if(n==f){
                resmin=max(n-3,0);
                ra=1;
            }else{
                resmin=n;
                int ret;
                if(n<=f){
                    for(i=1;(i<<1)<f;++i){
                        ret=test(i,f-i,n-2);
                        if(ret<resmin){
                            resmin=ret;
                            ra=i;
                        }
                    }
                }
            }
            vector<int>res(n);
            int cur=0;
            if(resmin<n){
                get(ra,f-ra,res);
                printf("%d\n",resmin);
                for(i=res.size()-1;i>=0;--i)putchar(at[cur^=res[i]]);
                putchar('\n');
            }else puts("IMPOSSIBLE");
        }
    }
    return 0;
}


#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int test(int a,int b){
    int n=a;
    int total=0;
    int ne;
    while(a!=1&&b!=1){
        ne=a%b;
        total+=(a-ne)/b;
        a=ne;
        swap(a,b);
    }
    total+=a-1;
    return total;
}
vector<int>res;
int rev;
int rest;
char at[]={'T','B'};
void get(int a,int b,int n){
    int sw=0;
    int total=0;
    int ne;
    int cnt;
    vector<int>cur;
    cur.reserve(n);
    int i;
    if(a<b)swap(a,b);
    cur.push_back(0);
    while(a!=1&&b!=1){
        ne=a%b;
        cnt=(a-ne)/b;
        for(i=0;i<cnt;++i)cur.push_back(sw);
        a=ne;
        swap(a,b);
        sw^=1;
    }
    for(i=1;i<a;++i)cur.push_back(sw);
    int crev=0;
    for(i=1;i<n-1;++i){
        if(cur[i]!=(i&1))++total;
    }
    if(total>n-2-total){
        total=n-2-total;
        crev=1;
    }
    cur[0]=crev;
    cur.push_back((crev^cur.size())&1);
    if(total<rest){
        res=cur;
        rest=total;
    }
    return;
}
int main(){
    int n,f;
    scanf("%d%d",&n,&f);
    rest=n;
    int i;
    for(i=f/2+1;i<f;++i){
        if(gcd(i,f)==1&&test(f-i,i)==n-2)get(f-i,i,n);
    }
    if(res.size()){
        printf("%d\n",rest);
        for(i=res.size()-1;i>=0;--i)putchar(at[res[i]^res.back()]);
        putchar('\n');
    }else puts("IMPOSSIBLE");
    return 0;
}


//Tornike Mandzulashvili
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#define PI 3.14159265
#define INF 2000000000

using namespace std;
string s;
int ans1,ans2,n,r,i,j,raod,num,mistake,a,b,aa,bb;

main()
{
    //  freopen("text.in","r",stdin);
   //   freopen("text.out","w",stdout);

      cin>>n>>r;
      raod=INF;
      for (aa=1;aa<=r-1;aa++)
      {
          b=r;
          a=aa;
          num=0;
          mistake=0;
          while (a>1 || b>1)
          {
                if (a==0 || b==0)
                {
                         num=INF;
                         break;
                         }
                if (b==1)
                {
                         num+=a;
                         mistake+=a-1;
                         break;
                         }else
                         if (a==1)
                         {
                                  num+=b;
                                  mistake+=b-2;
                                  break;
                                  }

                if (a>b)
                {
                        mistake+=a/b-1;
                        num+=a/b;
                        a=a%b;
                        }else
                        {
                              mistake+=b/a-1;
                              num+=b/a;
                              b=b%a;
                              }
                }
                if (raod>mistake && num==n)
                {
                             raod=mistake;ans1=aa;ans2=r;
                             }
      }

  /*    for (aa=1;aa<=r-1;aa++)
      {
          b=aa;
          a=r;
          num=0;
          mistake=0;
          while (a>1 || b>1)
          {
                if (a==0 || b==0)
                {
                         num=INF;
                         break;
                         }
                if (b==1)
                {
                         num+=a;
                         mistake+=a-1;
                         break;
                         }else
                         if (a==1)
                         {
                                  num+=b;
                                  mistake+=b-2;
                                  break;
                                  }

                if (a>b)
                {
                        mistake+=a/b-1;
                        num+=a/b;
                        a=a%b;
                        }else
                        {
                              mistake+=b/a-1;
                              num+=b/a;
                              b=b%a;
                              }
                }
                if (raod>mistake && num==n)
                {
                             raod=mistake;ans1=aa;ans2=r;
                             }
      }
      */

      a=ans1;
      b=ans2;
      num=0;
      mistake=0;
      while (a>1 || b>1)
          {
                if (b==1)
                {
                         num+=a;
                         mistake+=a-1;
                         for (i=1;i<=a;i++)
                         s+='T';
                         break;
                         }else
                         if (a==1)
                         {
                                  num+=b;
                                  mistake+=b-2;
                                  for (i=1;i<b;i++)
                                  s+='B';
                                  s+='T';
                                  break;
                                  }

                if (a>b)
                {
                        mistake+=a/b-1;
                        num+=a/b;
                        for (i=1;i<=a/b;i++)
                        s+='T';
                        a=a%b;
                        }else
                        {
                              mistake+=b/a-1;
                              num+=b/a;
                              for (i=1;i<=b/a;i++)
                              s+='B';
                              b=b%a;
                              }
                }
                if (raod==INF)
                {
               cout<<"IMPOSSIBLE"<<endl;
               return 0;
                              }
      cout<<raod<<endl;
      for (i=s.size()-1;i>=0;i--)
      cout<<s[i];
      cout<<endl;
}


//Tornike Mandzulashvili
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#define PI 3.14159265
#define INF 2000000000

using namespace std;
string s;
int ans1,ans2,n,r,i,j,raod,num,mistake,a,b,aa,bb;

main()
{
   //   freopen("text.in","r",stdin);
  //    freopen("text.out","w",stdout);

      cin>>n>>r;
      if (r<n)
      {
               cout<<"IMPOSSIBLE"<<endl;
               return 0;
      }
      raod=INF;
      for (aa=1;aa<=r-1;aa++)
      {
          b=r;
          a=aa;
          num=0;
          mistake=0;
          while (a>1 || b>1)
          {
                if (a==0 || b==0)
                {
                         num=INF;
                         break;
                         }
                if (b==1)
                {
                         num+=a;
                         mistake+=a-1;
                         break;
                         }else
                         if (a==1)
                         {
                                  num+=b;
                                  mistake+=b-2;
                                  break;
                                  }

                if (a>b)
                {
                        mistake+=a/b-1;
                        num+=a/b;
                        a=a%b;
                        }else
                        {
                              mistake+=b/a-1;
                              num+=b/a;
                              b=b%a;
                              }
                }
                if (raod>mistake && num==n)
                {
                             raod=mistake;ans1=aa;ans2=r;
                             }
      }

      for (aa=1;aa<=r-1;aa++)
      {
          b=aa;
          a=r;
          num=0;
          mistake=0;
          while (a>1 || b>1)
          {
                if (a==0 || b==0)
                {
                         num=INF;
                         break;
                         }
                if (b==1)
                {
                         num+=a;
                         mistake+=a-1;
                         break;
                         }else
                         if (a==1)
                         {
                                  num+=b;
                                  mistake+=b-2;
                                  break;
                                  }

                if (a>b)
                {
                        mistake+=a/b-1;
                        num+=a/b;
                        a=a%b;
                        }else
                        {
                              mistake+=b/a-1;
                              num+=b/a;
                              b=b%a;
                              }
                }
                if (raod>mistake && num==n)
                {
                             raod=mistake;ans1=aa;ans2=r;
                             }
      }

      a=ans1;
      b=ans2;
      num=0;
      mistake=0;
      while (a>1 || b>1)
          {
                if (b==1)
                {
                         num+=a;
                         mistake+=a-1;
                         for (i=1;i<=a;i++)
                         s+='T';
                         break;
                         }else
                         if (a==1)
                         {
                                  num+=b;
                                  mistake+=b-2;
                                  for (i=1;i<b;i++)
                                  s+='B';
                                  s+='T';
                                  break;
                                  }

                if (a>b)
                {
                        mistake+=a/b-1;
                        num+=a/b;
                        for (i=1;i<=a/b;i++)
                        s+='T';
                        a=a%b;
                        }else
                        {
                              mistake+=b/a-1;
                              num+=b/a;
                              for (i=1;i<=b/a;i++)
                              s+='B';
                              b=b%a;
                              }
                }
      cout<<raod<<endl;
      for (i=s.size()-1;i>=0;i--)
      cout<<s[i];
      cout<<endl;
}


//Tornike Mandzulashvili
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#define PI 3.14159265
#define INF 2000000000

using namespace std;
string s;
int ans1,ans2,n,r,i,j,raod,num,mistake,a,b,aa,bb;

main()
{
  //   freopen("text.in","r",stdin);
  //    freopen("text.out","w",stdout);

      cin>>n>>r;
      raod=INF;
      for (aa=1;aa<=r-1;aa++)
      {
          b=r;
          a=aa;
          num=0;
          mistake=0;
          while (a>1 || b>1)
          {
                if (a==0 || b==0)
                {
                         mistake=INF;
                         break;
                         }
                if (b==1)
                {
                         num+=a;
                         mistake+=a-1;
                         break;
                         }else
                         if (a==1)
                         {
                                  num+=b;
                                  mistake+=b-2;
                                  break;
                                  }

                if (a>b)
                {
                        mistake+=a/b-1;
                        num+=a/b;
                        a=a%b;
                        }else
                        {
                              mistake+=b/a-1;
                              num+=b/a;
                              b=b%a;
                              }
                }
                if (raod>mistake && num==n)
                {
                             raod=mistake;ans1=aa;ans2=r;
                             }
      }

      for (aa=1;aa<=r-1;aa++)
      {
          b=aa;
          a=r;
          num=0;
          mistake=0;
          while (a>1 || b>1)
          {
                if (a==0 || b==0)
                {
                         mistake=INF;
                         break;
                         }
                if (b==1)
                {
                         num+=a;
                         mistake+=a-1;
                         break;
                         }else
                         if (a==1)
                         {
                                  num+=b;
                                  mistake+=b-2;
                                  break;
                                  }

                if (a>b)
                {
                        mistake+=a/b-1;
                        num+=a/b;
                        a=a%b;
                        }else
                        {
                              mistake+=b/a-1;
                              num+=b/a;
                              b=b%a;
                              }
                }
                if (raod>mistake && num==n)
                {
                             raod=mistake;ans1=r;ans2=aa;
                             }
      }

      a=ans1;
      b=ans2;
      num=0;
      mistake=0;
      while (a>1 || b>1)
          {
                if (b==1)
                {
                         num+=a;
                         mistake+=a-1;
                         for (i=1;i<=a;i++)
                         s+='T';
                         break;
                         }else
                         if (a==1)
                         {
                                  num+=b;
                                  mistake+=b-2;
                                  for (i=1;i<b;i++)
                                  s+='B';
                                  s+='T';
                                  break;
                                  }

                if (a>b)
                {
                        mistake+=a/b-1;
                        num+=a/b;
                        for (i=1;i<=a/b;i++)
                        s+='T';
                        a=a%b;
                        }else
                        {
                              mistake+=b/a-1;
                              num+=b/a;
                              for (i=1;i<=b/a;i++)
                              s+='B';
                              b=b%a;
                              }
                }
                if (raod==INF)
                {
               cout<<"IMPOSSIBLE"<<endl;
               return 0;
                              }
      cout<<raod<<endl;
      for (i=s.size()-1;i>=0;i--)
      cout<<s[i];
      cout<<endl;
}


//Tornike Mandzulashvili
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#define PI 3.14159265
#define INF 2000000000

using namespace std;
string s;
int ans1,ans2,n,r,i,j,raod,num,mistake,a,b,aa,bb;

main()
{
   //   freopen("text.in","r",stdin);
   //   freopen("text.out","w",stdout);

      cin>>n>>r;
      raod=INF;
      for (aa=1;aa<=r-1;aa++)
      {
          b=r;
          a=aa;
          num=0;
          mistake=0;
          while (a>1 || b>1)
          {
                if (a==0 || b==0)
                {
                         num=INF;
                         break;
                         }
                if (b==1)
                {
                         num+=a;
                         mistake+=a-1;
                         break;
                         }else
                         if (a==1)
                         {
                                  num+=b;
                                  mistake+=b-2;
                                  break;
                                  }

                if (a>b)
                {
                        mistake+=a/b-1;
                        num+=a/b;
                        a=a%b;
                        }else
                        {
                              mistake+=b/a-1;
                              num+=b/a;
                              b=b%a;
                              }
                }
                if (raod>mistake && num==n)
                {
                             raod=mistake;ans1=aa;ans2=r;
                             }
      }

      for (aa=1;aa<=r-1;aa++)
      {
          b=aa;
          a=r;
          num=0;
          mistake=0;
          while (a>1 || b>1)
          {
                if (a==0 || b==0)
                {
                         num=INF;
                         break;
                         }
                if (b==1)
                {
                         num+=a;
                         mistake+=a-1;
                         break;
                         }else
                         if (a==1)
                         {
                                  num+=b;
                                  mistake+=b-2;
                                  break;
                                  }

                if (a>b)
                {
                        mistake+=a/b-1;
                        num+=a/b;
                        a=a%b;
                        }else
                        {
                              mistake+=b/a-1;
                              num+=b/a;
                              b=b%a;
                              }
                }
                if (raod>mistake && num==n)
                {
                             raod=mistake;ans1=aa;ans2=r;
                             }
      }

      a=ans1;
      b=ans2;
      num=0;
      mistake=0;
      while (a>1 || b>1)
          {
                if (b==1)
                {
                         num+=a;
                         mistake+=a-1;
                         for (i=1;i<=a;i++)
                         s+='T';
                         break;
                         }else
                         if (a==1)
                         {
                                  num+=b;
                                  mistake+=b-2;
                                  for (i=1;i<b;i++)
                                  s+='B';
                                  s+='T';
                                  break;
                                  }

                if (a>b)
                {
                        mistake+=a/b-1;
                        num+=a/b;
                        for (i=1;i<=a/b;i++)
                        s+='T';
                        a=a%b;
                        }else
                        {
                              mistake+=b/a-1;
                              num+=b/a;
                              for (i=1;i<=b/a;i++)
                              s+='B';
                              b=b%a;
                              }
                }
                if (raod==INF)
                {
               cout<<"IMPOSSIBLE"<<endl;
               return 0;
                              }
      cout<<raod<<endl;
      for (i=s.size()-1;i>=0;i--)
      cout<<s[i];
      cout<<endl;
}


//Tornike Mandzulashvili
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#define PI 3.14159265
#define INF 2000000000

using namespace std;
string s;
int ans1,ans2,n,r,i,j,raod,num,mistake,a,b,aa,bb;

main()
{
  //   freopen("text.in","r",stdin);
  //    freopen("text.out","w",stdout);

      cin>>n>>r;if (n==1 && r==1)

     {
    cout<<0<<endl;
   cout<<"T"<<endl;
  return 0;
    }
      raod=INF;
      for (aa=1;aa<=r-1;aa++)
      {
          b=r;
          a=aa;
          num=0;
          mistake=0;
          while (a>1 || b>1)
          {
                if (a==0 || b==0)
                {
                         mistake=INF;
                         break;
                         }
                if (b==1)
                {
                         num+=a;
                         mistake+=a-1;
                         break;
                         }else
                         if (a==1)
                         {
                                  num+=b;
                                  mistake+=b-2;
                                  break;
                                  }

                if (a>b)
                {
                        mistake+=a/b-1;
                        num+=a/b;
                        a=a%b;
                        }else
                        {
                              mistake+=b/a-1;
                              num+=b/a;
                              b=b%a;
                              }
                }
                if (raod>mistake && num==n)
                {
                             raod=mistake;ans1=aa;ans2=r;
                             }
      }

      for (aa=1;aa<=r-1;aa++)
      {
          b=aa;
          a=r;
          num=0;
          mistake=0;
          while (a>1 || b>1)
          {
                if (a==0 || b==0)
                {
                         mistake=INF;
                         break;
                         }
                if (b==1)
                {
                         num+=a;
                         mistake+=a-1;
                         break;
                         }else
                         if (a==1)
                         {
                                  num+=b;
                                  mistake+=b-2;
                                  break;
                                  }

                if (a>b)
                {
                        mistake+=a/b-1;
                        num+=a/b;
                        a=a%b;
                        }else
                        {
                              mistake+=b/a-1;
                              num+=b/a;
                              b=b%a;
                              }
                }
                if (raod>mistake && num==n)
                {
                             raod=mistake;ans1=r;ans2=aa;
                             }
      }

      a=ans1;
      b=ans2;
      num=0;
      mistake=0;
      while (a>1 || b>1)
          {
                if (b==1)
                {
                         num+=a;
                         mistake+=a-1;
                         for (i=1;i<=a;i++)
                         s+='T';
                         break;
                         }else
                         if (a==1)
                         {
                                  num+=b;
                                  mistake+=b-2;
                                  for (i=1;i<b;i++)
                                  s+='B';
                                  s+='T';
                                  break;
                                  }

                if (a>b)
                {
                        mistake+=a/b-1;
                        num+=a/b;
                        for (i=1;i<=a/b;i++)
                        s+='T';
                        a=a%b;
                        }else
                        {
                              mistake+=b/a-1;
                              num+=b/a;
                              for (i=1;i<=b/a;i++)
                              s+='B';
                              b=b%a;
                              }
                }
                if (raod==INF)
                {
               cout<<"IMPOSSIBLE"<<endl;
               return 0;
                              }
      cout<<raod<<endl;
      for (i=s.size()-1;i>=0;i--)
      cout<<s[i];
      cout<<endl;
}


#include<stdio.h>
#include<algorithm>
using namespace std;
int mn=1000001,sv;
char lst;
int n;
int ar[1000002];
void fnc(int sm,int pr,int id,int e,char ls)
{
   //  printf("fnc %d %d %d %d %d\n",sm,pr,id,e,ls);
    if(id == n)
    {
      if(sm == 1 && pr == 1 && ls == 0)
      {
          if(e < mn)
          {
           mn=e;
           sv=-1;
           //lst=ls;
          }
      }
      return;
    }
    if(pr == 1 && sm == 1)
    return;
     if(pr == 1)
    {
     fnc(1,1,id+sm-1,e+sm-2,1-ls);
     return;
    }
    if(pr == 0)
    return;
    if(sm/pr+id > n+1  || sm == 0) // n+1
    return;
     fnc(pr,sm%pr,id+sm/pr,e+sm/pr-1,1-ls);
}
char st;
void fnc2(int sm,int pr,int id,char ls)
{
 //printf("%d %d %d %d\n",sm,pr,id,ls);
 //scanf("%*c");
    if(id == n)
      return;
    int i,tm;

    if(ls == 0)
    ar[id]='T';
    else
    ar[id]='B';
    if(sm-pr < pr)
     ls=1-ls;

     fnc2(max(sm-pr,pr),min(sm-pr,pr),id+1,ls);
}
FILE*f1=stdin;//fopen("in.in","r");
int main()
{
int rs;
    int i,sm;
    fscanf(f1,"%d%d",&n,&rs);
      // printf("\n%d",n);
    //sm=rs;
    sv=0;
    for(i=1;i<rs;i++)
    {
      fnc(rs,i,1,0,0);
      if(sv == -1)
      {
      sv=i;
      st=0;
      }
      fnc(rs,i,1,0,1);
      if(sv == -1)
      {
      sv=i;
      st=1;
      }
    }
    if(mn == 1000001)
    printf("IMPOSSIBLE");
    else
    {
    printf("%d\n",mn);
      fnc2(rs,sv,1,st);
    printf("T");
    for(i=n-1;i>=1;i--)
    printf("%c",ar[i]);
   }

   printf("\n");
    scanf("%*d");
}
    /*if(id == n+1)
    {
      if(sm == 1 && pr == 0)
      {
          if(e < mn)
          {
           mn=e;
           sv=-1;
           lst=ls;
          }
      }
      return;
    }
    /*if(pr == 1 && sm == 1)
    return;
    if(pr == 1)
    {
     fnc(1,1,id+sm-1,e+sm-2,1-ls);
     return;
    }*/


#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
using namespace std;
int mn=1000001,sv;
char lst;
int n;
int ar[1000002];
void fnc(int sm,int pr,int id,int e,char ls)
{
   //  printf("fnc %d %d %d %d %d\n",sm,pr,id,e,ls);
    if(id == n)
    {
      if(sm == 1 && pr == 1 && ls == 0)
      {
          if(e < mn)
          {
           mn=e;
           sv=-1;
           //lst=ls;
          }
      }
      return;
    }
    if(pr == 1 && sm == 1)
    return;
     if(pr == 1)
    {
     fnc(1,1,id+sm-1,e+sm-2,1-ls);
     return;
    }
    if(pr == 0)
    return;
    if(sm/pr+id > n+1  || sm == 0) // n+1
    return;
     fnc(pr,sm%pr,id+sm/pr,e+sm/pr-1,1-ls);
}
char st;
void fnc2(int sm,int pr,int id,char ls)
{
 //printf("%d %d %d %d\n",sm,pr,id,ls);
 //scanf("%*c");
    if(id == n)
      return;
    int i,tm;

    if(ls == 0)
    ar[id]='T';
    else
    ar[id]='B';
    if(sm-pr < pr)
     ls=1-ls;

     fnc2(max(sm-pr,pr),min(sm-pr,pr),id+1,ls);
}
FILE*f1=stdin;//fopen("in.in","r");
int main()
{
int rs;
    int i,sm;
    fscanf(f1,"%d%d",&n,&rs);
      // printf("\n%d",n);
    //sm=rs;
    sv=0;
    for(i=1;i<rs;i++)
    {
      fnc(rs,i,1,0,0);
      if(sv == -1)
      {
      sv=i;
      st=0;
      }
      fnc(rs,i,1,0,1);
      if(sv == -1)
      {
      sv=i;
      st=1;
      }
    }
    if(n == 1 || rs == 1)
    {
    printf("0\nT\n");
    exit(0);
    }
    if(mn == 1000001)
    printf("IMPOSSIBLE");
    else
    {
    printf("%d\n",mn);
      fnc2(rs,sv,1,st);
    printf("T");
    for(i=n-1;i>=1;i--)
    printf("%c",ar[i]);
   }

   printf("\n");
    scanf("%*d");
}
    /*if(id == n+1)
    {
      if(sm == 1 && pr == 0)
      {
          if(e < mn)
          {
           mn=e;
           sv=-1;
           lst=ls;
          }
      }
      return;
    }
    /*if(pr == 1 && sm == 1)
    return;
    if(pr == 1)
    {
     fnc(1,1,id+sm-1,e+sm-2,1-ls);
     return;
    }*/


#include<stdio.h>
#include<algorithm>
using namespace std;
int mn=1000001,sv;
char lst,n;
int ar[1000002];
void fnc(int sm,int pr,int id,int e,char ls)
{
   //  printf("fnc %d %d %d %d %d\n",sm,pr,id,e,ls);
    if(id == n)
    {
      if(sm == 1 && pr == 1 && ls == 0)
      {
          if(e < mn)
          {
           mn=e;
           sv=-1;
           //lst=ls;
          }
      }
      return;
    }
    if(pr == 1 && sm == 1)
    return;
     if(pr == 1)
    {
     fnc(1,1,id+sm-1,e+sm-2,1-ls);
     return;
    }
    if(pr == 0)
    return;
    if(sm/pr+id > n+1  || sm == 0) // n+1
    return;
     fnc(pr,sm%pr,id+sm/pr,e+sm/pr-1,1-ls);
}
char st;
void fnc2(int sm,int pr,int id,char ls)
{
 //printf("%d %d %d %d\n",sm,pr,id,ls);
 //scanf("%*c");
    if(id == n)
      return;
    int i,tm;

    if(ls == 0)
    ar[id]='T';
    else
    ar[id]='B';
    if(sm-pr < pr)
     ls=1-ls;

     fnc2(max(sm-pr,pr),min(sm-pr,pr),id+1,ls);
}

int main()
{
int rs;
    int i,sm;
    scanf("%d%d",&n,&rs);
    //sm=rs;
    int sv=0;
    for(i=1;i<rs;i++)
    {
      fnc(rs,i,1,0,0);
      if(sv == -1)
      {
      sv=i;
      st=0;
      }
      fnc(rs,i,1,0,1);
      if(sv == -1)
      {
      sv=i;
      st=1;
      }
    }
    if(mn == 1000001)
    printf("IMPOSSIBLE");
    else
    {
    printf("%d\n",mn);
      fnc2(rs,sv,1,st);
    printf("T");
    for(i=n-1;i>=1;i--)
    printf("%c",ar[i]);
   }
   printf("\n");
    scanf("%*d");
}
    /*if(id == n+1)
    {
      if(sm == 1 && pr == 0)
      {
          if(e < mn)
          {
           mn=e;
           sv=-1;
           lst=ls;
          }
      }
      return;
    }
    /*if(pr == 1 && sm == 1)
    return;
    if(pr == 1)
    {
     fnc(1,1,id+sm-1,e+sm-2,1-ls);
     return;
    }*/


#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
using namespace std;
int mn=1000001,sv;
char lst;
int n;
int ar[1000002];
void fnc(int sm,int pr,int id,int e,char ls)
{
   //  printf("fnc %d %d %d %d %d\n",sm,pr,id,e,ls);
    if(id == n)
    {
      if(sm == 1 && pr == 1 && ls == 0)
      {
          if(e < mn)
          {
           mn=e;
           sv=-1;
           //lst=ls;
          }
      }
      return;
    }
    if(pr == 1 && sm == 1)
    return;
     if(pr == 1)
    {
     fnc(1,1,id+sm-1,e+sm-2,1-ls);
     return;
    }
    if(pr == 0)
    return;
    if(sm/pr+id > n+1  || sm == 0) // n+1
    return;
     fnc(pr,sm%pr,id+sm/pr,e+sm/pr-1,1-ls);
}
char st;
void fnc2(int sm,int pr,int id,char ls)
{
 //printf("%d %d %d %d\n",sm,pr,id,ls);
 //scanf("%*c");
    if(id == n)
      return;
    int i,tm;

    if(ls == 0)
    ar[id]='T';
    else
    ar[id]='B';
    if(sm-pr < pr)
     ls=1-ls;

     fnc2(max(sm-pr,pr),min(sm-pr,pr),id+1,ls);
}
FILE*f1=stdin;//fopen("in.in","r");
int main()
{
int rs;
    int i,sm;
    fscanf(f1,"%d%d",&n,&rs);
      // printf("\n%d",n);
    //sm=rs;
    sv=0;
    for(i=1;i<rs;i++)
    {
      fnc(rs,i,1,0,0);
      if(sv == -1)
      {
      sv=i;
      st=0;
      }
      fnc(rs,i,1,0,1);
      if(sv == -1)
      {
      sv=i;
      st=1;
      }
    }
    if(n == 1 && rs == 1)
    {
    printf("0\nT\n");
    exit(0);
    }
    if(mn == 1000001)
    printf("IMPOSSIBLE");
    else
    {
    printf("%d\n",mn);
      fnc2(rs,sv,1,st);
    printf("T");
    for(i=n-1;i>=1;i--)
    printf("%c",ar[i]);
   }

   printf("\n");
    scanf("%*d");
}
    /*if(id == n+1)
    {
      if(sm == 1 && pr == 0)
      {
          if(e < mn)
          {
           mn=e;
           sv=-1;
           lst=ls;
          }
      }
      return;
    }
    /*if(pr == 1 && sm == 1)
    return;
    if(pr == 1)
    {
     fnc(1,1,id+sm-1,e+sm-2,1-ls);
     return;
    }*/


#include<stdio.h>
#include<algorithm>
using namespace std;
int mn=1000001,sv;
char lst,n;
int ar[1000002];
void fnc(int sm,int pr,int id,int e,char ls)
{
   //  printf("fnc %d %d %d %d %d\n",sm,pr,id,e,ls);
    if(id == n)
    {
      if(sm == 1 && pr == 1 && ls == 0)
      {
          if(e < mn)
          {
           mn=e;
           sv=-1;
           //lst=ls;
          }
      }
      return;
    }
    if(pr == 1 && sm == 1)
    return;
     if(pr == 1)
    {
     fnc(1,1,id+sm-1,e+sm-2,1-ls);
     return;
    }
    if(pr == 0)
    return;
    if(sm/pr+id > n+1  || sm == 0) // n+1
    return;
     fnc(pr,sm%pr,id+sm/pr,e+sm/pr-1,1-ls);
}
char st;
void fnc2(int sm,int pr,int id,char ls)
{
 //printf("%d %d %d %d\n",sm,pr,id,ls);
 //scanf("%*c");
    if(id == n)
      return;
    int i,tm;

    if(ls == 0)
    ar[id]='T';
    else
    ar[id]='B';
    if(sm-pr < pr)
     ls=1-ls;

     fnc2(max(sm-pr,pr),min(sm-pr,pr),id+1,ls);
}

int main()
{
int rs;
    int i,sm;
    scanf("%d%d",&n,&rs);
    //sm=rs;
    sv=0;
    for(i=1;i<rs;i++)
    {
      fnc(rs,i,1,0,0);
      if(sv == -1)
      {
      sv=i;
      st=0;
      }
      fnc(rs,i,1,0,1);
      if(sv == -1)
      {
      sv=i;
      st=1;
      }
    }
    if(mn == 1000001)
    printf("IMPOSSIBLE");
    else
    {
    printf("%d\n",mn);
      fnc2(rs,sv,1,st);
    printf("T");
    for(i=n-1;i>=1;i--)
    printf("%c",ar[i]);
   }
   printf("\n");
    scanf("%*d");
}
    /*if(id == n+1)
    {
      if(sm == 1 && pr == 0)
      {
          if(e < mn)
          {
           mn=e;
           sv=-1;
           lst=ls;
          }
      }
      return;
    }
    /*if(pr == 1 && sm == 1)
    return;
    if(pr == 1)
    {
     fnc(1,1,id+sm-1,e+sm-2,1-ls);
     return;
    }*/


#include<stdio.h>
#include<algorithm>
using namespace std;
int mn=1000001,sv;
char lst,n;
int ar[1000002];
void fnc(int sm,int pr,int id,int e,char ls)
{
   //  printf("fnc %d %d %d %d %d\n",sm,pr,id,e,ls);

    if(id == n)
    {
      if(sm == 1 && pr == 1 && ls == 0)
      {
          if(e < mn)
          {
           mn=e;
           sv=-1;
           //lst=ls;
          }
      }
      return;
    }
    if(pr == 1 && sm == 1)
    return;
     if(pr == 1)
    {
     fnc(1,1,id+sm-1,e+sm-2,1-ls);
     return;
    }
    if(pr == 0)
    return;
    if(sm/pr+id > n+1  || sm == 0) // n+1
    return;
     fnc(pr,sm%pr,id+sm/pr,e+sm/pr-1,1-ls);
}
char st;
void fnc2(int sm,int pr,int id,char ls)
{
 //printf("%d %d %d %d\n",sm,pr,id,ls);
 //scanf("%*c");
    if(id == n)
      return;
    int i,tm;

    if(ls == 0)
    ar[id]='T';
    else
    ar[id]='B';
    if(sm-pr < pr)
     ls=1-ls;

     fnc2(max(sm-pr,pr),min(sm-pr,pr),id+1,ls);
}

int main()
{
int rs;
    int i,sm;
    scanf("%d%d",&n,&rs);
    //sm=rs;

    for(i=1;i<rs;i++)
    {
      fnc(rs,i,1,0,0);
      if(sv == -1)
      {
      sv=i;
      st=0;
      }
      fnc(rs,i,1,0,1);
      if(sv == -1)
      {
      sv=i;
      st=1;
      }
    }
    if(mn == 1000001)
    printf("IMPOSSIBLE");
    else
    {
    printf("%d\n",mn);
      fnc2(rs,sv,1,st);
    printf("T");
    for(i=n-1;i>=1;i--)
    printf("%c",ar[i]);
   }
   printf("\n");
    scanf("%*d");
}
    /*if(id == n+1)
    {
      if(sm == 1 && pr == 0)
      {
          if(e < mn)
          {
           mn=e;
           sv=-1;
           lst=ls;
          }
      }
      return;
    }
    /*if(pr == 1 && sm == 1)
    return;
    if(pr == 1)
    {
     fnc(1,1,id+sm-1,e+sm-2,1-ls);
     return;
    }*/


#include <cstdio>
#include <set>
using namespace std;

#define inf 1000000

int n, m, x, xsol, tp, ng;
pair<int, int> cr;

pair<int, int> cmmdc(int a, int b)
{
    if(a==1 && b==1)
        return make_pair(1, 0);

    if(a==1)
        return make_pair(b, b-1);
    if(b==1)
        return make_pair(a, a-2);

    if(a==0 || b==0)
        return make_pair(-inf, -inf);

    pair<int, int> sol;
    if(a>b)
    {
        sol=cmmdc(a%b, b);
        sol.first+=a/b;
        sol.second+=a/b-1;
    }
    else
    {
        sol=cmmdc(a, b%a);
        sol.first+=b/a;
        sol.second+=b/a-1;
        if(a==1)
            sol.second--;
    }
    return sol;
}

int reconst(int a, int b)
{
    if(a==1 && b==1)
    {
        printf("T");
        return 1;
    }

    int ras;
    if(a>b)
    {
        ras=reconst(a-b, b);
        if(a-b<=b)
            ras=1-ras;
    }
    else
    {
        ras=reconst(a, b-a);
        if(b-a<=a)
            ras=1-ras;
    }

    if(ras==1)
        printf("T");
    else
        printf("B");

    return ras;
}

int main()
{
  //  freopen("data.in", "r", stdin);
 //   freopen("data.out", "w", stdout);

    scanf("%d%d", &n, &x);
    ng=inf;
    for(int i=1; i<=x; ++i)
    {
        cr=cmmdc(i, x);
        if(cr.first==n && cr.second<ng)
        {
            ng=cr.second;
            xsol=i;
            tp=1;
        }
        cr=cmmdc(x, i);
        if(cr.first==n && cr.second<ng)
        {
            ng=cr.second;
            xsol=i;
            tp=2;
        }
    }

    if(ng==inf)
    {
        printf("IMPOSSIBLE\n");
        return 0;
    }

    printf("%d\n", ng);
    if(tp==1)
        ng=reconst(xsol, x);
    else
        ng=reconst(x, xsol);

    return 0;
}


#include <cstdio>
#include <algorithm>

using namespace std;

char buff[1000005];
char res[1000005];
int best = 2000000;
int n, r;

void make(int T, int B) {
    int i = n-1;
    while (n >= 0 && T != 0 && B != 0) {
        if (T >= B) {
            T -= B;
            buff[i--] = 'T';
        } else {
            B -= T;
            buff[i--] = 'B';
        }
    }
    if (i != -1 || !(T == 0 && B == 1)) return;
    int err = 0;
    for (i = 1; i < n; i++) if (buff[i] == buff[i-1]) err++;
    if (err < best) {
        best = err;
        for (i = 0; i < n; i++) res[i] = buff[i];
    }
}

int main() {
    scanf("%d %d", &n, &r);
    for (int i = 0; i <= r; i++) {
        make(i,r);
        make(r,i);
    }
    if (best == 2000000) printf("IMPOSSIBLE\n");
    else {
        printf("%d\n%s\n", best, res);
    }
    return 0;
}


#include <iostream>
#define INF ~0u>>1
#define mn 1000010
using namespace std;

char move[mn],res[mn];
int ans=INF,n,r,cur;

void check(int x,int y){
    for(cur=n-1;x*y!=0 && cur>=0;cur--)
        if(x>=y) x-=y,move[cur]='T';
        else y-=x,move[cur]='B';
    if(cur!=-1 || !(x==0 && y==1)) return;
    int tmp=0;
    for(int i=1;i<n;i++)
        if(move[i]==move[i-1]) tmp++;
    if(tmp<ans){
        ans=tmp;
        for(int i=0;i<n;i++)
            res[i]=move[i];
    }
}

int main(){
    cin>>n>>r;
    for(int i=0;i<=r;i++)
        check(i,r),check(r,i);
    if(ans==INF) cout<<"IMPOSSIBLE"<<endl;
    else cout<<ans<<endl<<res<<endl;
}


#include <iostream>
#define INF ~0u>>1
#define mn 1000010
using namespace std;

char move[mn],res[mn];
int ans=INF,n,r,cur;

void check(int x,int y){
    for(cur=n-1;x*y>0 && cur>=0;cur--)
        if(x>=y) x-=y,move[cur]='T';
        else y-=x,move[cur]='B';
    if(cur!=-1 || !(x==0 && y==1)) return;
    int tmp=0;
    for(int i=1;i<n;i++)
        if(move[i]==move[i+1]) tmp++;
    if(tmp<ans){
        ans=tmp;
        for(int i=0;i<n;i++)
            res[i]=move[i];
    }
}

int main(){
    cin>>n>>r;
    for(int i=1;i<r;i++)
        check(i,r),check(r,i);
    if(ans==INF) cout<<"IMPOSSIBLE"<<endl;
    else cout<<ans<<endl<<res<<endl;
}


#include <iostream>
#define INF ~0u>>1
#define mn 1000010
using namespace std;

char move[mn],res[mn];
int ans=INF,n,r,cur;

void check(int x,int y){
    for(cur=n-1;x*y!=0 && cur>=0;cur--)
        if(x>=y) x-=y,move[cur]='T';
        else y-=x,move[cur]='B';
    if(cur!=-1 || !(x==0 && y==1)) return;
    int tmp=0;
    for(int i=1;i<n;i++)
        if(move[i]==move[i-1]) tmp++;
    if(tmp<ans){
        ans=tmp;
        for(int i=0;i<n;i++)
            res[i]=move[i];
    }
}

int main(){
    cin>>n>>r;
    for(int i=1;i<r;i++)
        check(i,r),check(r,i);
    if(ans==INF) cout<<"IMPOSSIBLE"<<endl;
    else cout<<ans<<endl<<res<<endl;
}


#include <iostream>
#include <cmath>
#include <string>
using namespace std;
int n,r,i,ans=1000000000;
const string im="IMPOSSIBLE";
char s1[1111111],s0[1111111];
inline void check(int x, int y){
	int l=0;
	while (x!=y){
		if (x>y){
			x-=y;
			s0[l]='T';
			l++;
		}else{
			y-=x;
			s0[l]='B';
			l++;
		}
	}
	if (l!=n-1) return;
	if (x+y!=2) return;
	s0[l]='T';
	int c=0;
	for(int i=1;i<=l;i++)
		if (s0[i]==s0[i-1])
			c++;
	if (c<ans){
		for(int i=0;i<=l;i++)
			s1[i]=s0[i];
		ans=c;
	}
}
int main (){
	cin>>n>>r;
	if (n==1){
		if (r==1)
			cout<<0<<endl<<"T"<<endl;
		else cout<<im<<endl;
		return 0;
	}
	for(i=1;i<r;i++){
		check(i,r);
	//	check(r,i);
	}
	if (ans==1000000000)
		cout<<im<<endl;
	else{
		cout<<ans<<endl;
		for(i=n-1;i>=0;i--)
			cout<<s1[i];
		cout<<endl;
	}
	return 0;
}


#include <iostream>
#define INF ~0u>>1
#define mn 1000010
using namespace std;

char move[mn],res[mn];
int ans=INF,n,r,cur;

void check(int x,int y){
	for(cur=n-1;x*y!=1 && cur>=0;cur--)
		if(x>=y) x-=y,move[cur]='T';
		else y-=x,move[cur]='B';
	if(cur!=0 || x*y!=1) return;
	move[0]='T';
	int tmp=0;
	for(int i=1;i<n;i++)
		if(move[i]==move[i-1]) tmp++;
	if(tmp<ans){
		ans=tmp;
		for(int i=0;i<n;i++)
			res[i]=move[i];
	}
}

int main(){
	cin>>n>>r;
	for(int i=0;i<=r;i++)
		check(i,r),check(r,i);
	if(ans==INF) cout<<"IMPOSSIBLE"<<endl;
	else cout<<ans<<endl<<res<<endl;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<string.h>
#include<cstring>
#include<stack>
#include<queue>
#include<cassert>
#include<cmath>
using namespace std;

#define LL long long int
#define PII pair<int,int>
#define PB push_back
#define MP make_pair
#define INF 1000000000
#define debug(args...) do {cerr << #args << ": "; dbg,args; cerr << endl;} while(0)

char fans[2000000];
int main(){
    int i,n,r,n1,n2;
    int ans = INF;
    cin >> n >> r;
    vector<pair<char,int>  >vv;
    for(i=0;i<=r;i++){
        n1 = i;
        n2 = r;
        int steps = 0;

        int mist = 0;
        vector<pair<char, int> >cv;
        char cc = 'B';
        while(n1 != 0){//n1 < n2
            int sub = max(1,((n2-1)/n1));
            mist += sub - 1;
            steps += sub;
            cv.PB(MP(cc, sub));
            if(cc == 'B')cc = 'T';
            else
                cc = 'B';
            int nn1 = n2 - sub*n1;
            int nn2 = n1;
            n1 = nn1;
            n2 = nn2;
        }
        if(n2 == 1 && cv.size() > 0){
            if(cv[cv.size() -1].first == 'B'){
                for(int j=0;j<(int)cv.size();j++){
                    if(cv[j].first == 'T')cv[j].first = 'B';
                    else cv[j].first = 'T';
                }
            }
            if(steps == n){
                if(ans > mist){
                    ans = mist;
                    vv = cv;
                }
            }
        }
    }
    if(ans == INF)
        cout<<"IMPOSSIBLE"<<endl;
    else{
        reverse(vv.begin(), vv.end());
        int inv = 0, lst =-1;
        LL n1=0, n2=1;
        for(i=0;i<(int)vv.size();i++){
            if(vv[i].first == 'T'){
                n1 += n2*vv[i].second;
                lst = n1;
            }
            else{
                n2 += n1*vv[i].second;
                lst = n2;
            }
        }
        if(lst != r)
            inv = 1;
        cout<<ans<<endl;
        int cur = 0;
        for(i=0;i<(int)vv.size();i++){
            for(int j=0;j<vv[i].second;j++){
                if(inv){
                    if(vv[i].first == 'T')vv[i].first = 'B';
                    else
                    vv[i].first = 'T';
                }
                fans[cur ++] = vv[i].first;
            }
        }
        fans[cur] = 0;

        printf("%s\n",fans);
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<string.h>
#include<cstring>
#include<stack>
#include<queue>
#include<cassert>
#include<cmath>
using namespace std;

#define LL long long int
#define PII pair<int,int>
#define PB push_back
#define MP make_pair
#define INF 1000000000
#define debug(args...) do {cerr << #args << ": "; dbg,args; cerr << endl;} while(0)

int main(){
    int i,n,r,n1,n2;
    int ans = INF;
    cin >> n >> r;
    vector<pair<char,int>  >vv;
    for(i=0;i<=r;i++){
        n1 = i;
        n2 = r;
        int steps = 0;
        int mist = 0;
        vector<pair<char, int> >cv;
        char cc = 'B';
        while(n1 != 0){//n1 < n2
            int sub = max(1,((n2-1)/n1));
            mist += sub - 1;
            steps += sub;
            cv.PB(MP(cc, sub));
            if(cc == 'B')cc = 'T';
            else
                cc = 'B';
            int nn1 = n2 - sub*n1;
            int nn2 = n1;
            n1 = nn1;
            n2 = nn2;
        }
        if(n2 == 1){
            if(steps == n){
                if(ans > mist){
                    ans = mist;
                    vv = cv;
                }

            }
        }
    }
    if(ans == INF)
        cout<<"IMPOSSIBLE"<<endl;
    else{
        reverse(vv.begin(), vv.end());
        cout<<ans<<endl;
        for(i=0;i<(int)vv.size();i++){
            for(int j=0;j<vv[i].second;j++){
                cout<<vv[i].first;
            }
        }
        cout<<endl;
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<string.h>
#include<cstring>
#include<stack>
#include<queue>
#include<cassert>
#include<cmath>
using namespace std;

#define LL long long int
#define PII pair<int,int>
#define PB push_back
#define MP make_pair
#define INF 1000000000
#define debug(args...) do {cerr << #args << ": "; dbg,args; cerr << endl;} while(0)

int main(){
    int i,n,r,n1,n2;
    int ans = INF;
    cin >> n >> r;
    vector<pair<char,int>  >vv;
    for(i=0;i<=r;i++){
        n1 = i;
        n2 = r;
        int steps = 0;
        int mist = 0;
        vector<pair<char, int> >cv;
        char cc = 'B';
        while(n1 != 0){//n1 < n2
            int sub = max(1,((n2-1)/n1));
            mist += sub - 1;
            steps += sub;
            cv.PB(MP(cc, sub));
            if(cc == 'B')cc = 'T';
            else
                cc = 'B';
            int nn1 = n2 - sub*n1;
            int nn2 = n1;
            n1 = nn1;
            n2 = nn2;
        }
        if(n2 == 1 && cv.size() > 0){
            if(cv[cv.size() -1].first == 'B'){
                for(int j=0;j<(int)cv.size();j++){
                    if(cv[j].first == 'T')cv[j].first = 'B';
                    else cv[j].first = 'T';
                }
            }
            if(steps == n){
                if(ans > mist){
                    ans = mist;
                    vv = cv;
                }
            }
        }
    }
    if(ans == INF)
        cout<<"IMPOSSIBLE"<<endl;
    else{
        reverse(vv.begin(), vv.end());
        int inv = 0, lst =-1;
        LL n1=0, n2=1;
        for(i=0;i<(int)vv.size();i++){
            if(vv[i].first == 'T'){
                n1 += n2*vv[i].second;
                lst = n1;
            }
            else{
                n2 += n1*vv[i].second;
                lst = n2;
            }
        }
        if(lst != r)
            inv = 1;
        cout<<ans<<endl;
        for(i=0;i<(int)vv.size();i++){
            for(int j=0;j<vv[i].second;j++){
                if(inv){
                    if(vv[i].first == 'T')vv[i].first = 'B';
                    else
                    vv[i].first = 'T';
                }
                cout<<vv[i].first;
            }
        }
        cout<<endl;
    }
    return 0;
}


#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<string.h>
#include<cstring>
#include<stack>
#include<queue>
#include<cassert>
#include<cmath>
using namespace std;

#define LL long long int
#define PII pair<int,int>
#define PB push_back
#define MP make_pair
#define INF 1000000000
#define debug(args...) do {cerr << #args << ": "; dbg,args; cerr << endl;} while(0)

int main(){
    int i,n,r,n1,n2;
    int ans = INF;
    cin >> n >> r;
    vector<pair<char,int>  >vv;
    for(i=0;i<=r;i++){
        n1 = i;
        n2 = r;
        int steps = 0;
        int mist = 0;
        vector<pair<char, int> >cv;
        char cc = 'B';
        while(n1 != 0){//n1 < n2
            mist += max(0,((n2-1)/n1) - 1);
            steps += max(1,((n2-1)/n1));
            cv.PB(MP(cc, max(1,((n2-1)/n1))));
            if(cc == 'B')cc = 'T';
            else
                cc = 'B';
            int nn1 = n2 - max(1, ((n2-1)/n1))*n1;
            int nn2 = n1;
            n1 = nn1;
            n2 = nn2;
        }
        if(n2 == 1){
            if(steps == n){
                if(ans > mist){
                    ans = mist;
                    vv = cv;
                }

            }
        }
    }
    if(ans == INF)
        cout<<"IMPOSSIBLE"<<endl;
    else{
        reverse(vv.begin(), vv.end());
        cout<<ans<<endl;
        for(i=0;i<(int)vv.size();i++){
            for(int j=0;j<vv[i].second;j++){
                cout<<vv[i].first;
            }
        }
        cout<<endl;
    }
    return 0;
}


// In the name of God

#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>

using namespace std;

const int INF = 1LL << 30;
vector <bool> s;
int n, r;

int main()
{
	ios::sync_with_stdio(false);
	cin >> n >> r;
	s.resize(n);
	int res = INF, x;
	for (int i = 0; i <= r; i++)
	{
		int moveNum = 0, wMove = 0, a = i, b = r;
		while (a != 0 && wMove < res)
		{
			moveNum += b / a;
			wMove += b / a - ((a == 1 && b != 1) ? 2 : 1);
			b %= a;
			swap(a, b);
		}
		if (b == 1 && moveNum == n && wMove < res)
			x = i, res = wMove;
	}
	if (res == INF)
		cout << "IMPOSSIBLE\n";
	else
	{
		for (int i = n - 1; i >= 0;)
			if (x < r)
			{
				s[i--] = 1;
				r -= x;
			}
			else
			{
				i -= x / r;
				x %= r;
			}
		cout << res << '\n';
		if (s[1])
		{
			for (int i = 0; i < n; i++)
				cout << (s[i] ? 'B' : 'T');
		}
		else
		{
			cout << 'T';
			for (int i = 1; i < n; i++)
				cout << (s[i] ? 'T' : 'B');
		}
		cout << '\n';
	}
	return 0;
}


// In the name of God

#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

const int INF = 1LL << 30;
vector <bool> s;
int n, r;

int main()
{
	ios::sync_with_stdio(false);
	cin >> n >> r;
	s.resize(n);
	int res = INF, x;
	for (int i = 0; i <= r; i++)
	{
		int moveNum = 0, wMove = 0, a = i, b = r;
		while (a != 0 && wMove < res)
		{
			int t = b / a;
			moveNum += t;
			wMove += t - ((a == 1 && b != 1) ? 2 : 1);
			b %= a;
			swap(a, b);
		}
		if (b == 1 && moveNum == n && wMove < res)
			x = i, res = wMove;
	}
	if (res == INF)
		cout << "IMPOSSIBLE\n";
	else
	{
		for (int i = n - 1; i >= 0; i--)
			if (x < r)
			{
				s[i] = 1;
				r -= x;
			}
			else
				x -= r;
		cout << res << '\n';
		if (s[1])
		{
			for (int i = 0; i < n; i++)
				cout << (s[i] ? 'B' : 'T');
		}
		else
		{
			cout << 'T';
			for (int i = 1; i < n; i++)
				cout << (s[i] ? 'T' : 'B');
		}
		cout << '\n';
	}
	return 0;
}


// In the name of God

#include <algorithm>
#include <iostream>

using namespace std;

const long long INF = 1LL << 60;
bool s[1000 * 1000];
int n, r;

int main()
{
	cin >> n >> r;
	long long res = INF, x;
	for (int i = 0; i <= r; i++)
	{
		int moveNum = 0, wMove = 0, a = i, b = r;
		while (a != 0)
		{
			moveNum += b / a;
			wMove += b / a - 1;
			if (a == 1 && b != 1)
				wMove--;
			b %= a;
			swap(a, b);
		}
		if (b == 1 && moveNum == n && wMove < res)
			x = i, res = wMove;
	}
	if (res == INF)
		cout << "IMPOSSIBLE\n";
	else
	{
		for (int i = n - 1; i >= 0; i--)
			if (x < r)
			{
				s[i] = 1;
				r -= x;
			}
			else
				x -= r;
		cout << res << '\n';
		ios::sync_with_stdio(false);
		if (s[1])
		{
			for (int i = 0; i < n; i++)
				cout << (s[i] ? 'B' : 'T');
		}
		else
		{
			cout << 'T';
			for (int i = 1; i < n; i++)
				cout << (s[i] ? 'T' : 'B');
		}
		cout << '\n';
	}
	return 0;
}


// In the name of God

#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

const int INF = 1LL << 30;
vector <bool> s;
int n, r;

int main()
{
	ios::sync_with_stdio(false);
	cin >> n >> r;
	s.resize(n);
	int res = INF, x;
	for (int i = 0; i <= r; i++)
	{
		int moveNum = 0, wMove = 0, a = i, b = r;
		while (a != 0 && wMove < res)
		{
			int t = b / a;
			moveNum += t;
			wMove += t - ((a == 1 && b != 1) ? 2 : 1);
			b -= t * a;
			swap(a, b);
		}
		if (b == 1 && moveNum == n && wMove < res)
			x = i, res = wMove;
	}
	if (res == INF)
		cout << "IMPOSSIBLE\n";
	else
	{
		for (int i = n - 1; i >= 0; i--)
			if (x < r)
			{
				s[i] = 1;
				r -= x;
			}
			else
				x -= r;
		cout << res << '\n';
		if (s[1])
		{
			for (int i = 0; i < n; i++)
				cout << (s[i] ? 'B' : 'T');
		}
		else
		{
			cout << 'T';
			for (int i = 1; i < n; i++)
				cout << (s[i] ? 'T' : 'B');
		}
		cout << '\n';
	}
	return 0;
}


// In the name of God

#include <iostream>
#include <cstdio>

using namespace std;

const int INF = 1LL << 30;
bool s[1000 * 1000];
int n, r;

int main()
{
	scanf("%d%d", &n, &r);
	int res = INF, x;
	for (int i = 0; i <= r; i++)
	{
		int moveNum = 0, wMove = 0, a = i, b = r;
		while (a != 0 && wMove < res)
		{
			moveNum += b / a;
			wMove += b / a - ((a == 1 && b != 1) ? 2 : 1);
			b %= a;
			swap(a, b);
		}
		if (b == 1 && moveNum == n && wMove < res)
			x = i, res = wMove;
	}
	if (res == INF)
		printf("IMPOSSIBLE\n");
	else
	{
		for (int i = n - 1; i >= 0; i--)
			if (x < r)
			{
				s[i] = 1;
				r -= x;
			}
			else
				x -= r;
		printf("%d\n", res);
		if (s[1])
		{
			for (int i = 0; i < n; i++)
				printf("%c", s[i] ? 'B' : 'T');
		}
		else
		{
			printf("%c", 'T');
			for (int i = 1; i < n; i++)
				printf("%c", s[i] ? 'T' : 'B');
		}
		printf("%c", '\n');
	}
	return 0;
}


// In the name of God

#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

const int INF = 1LL << 30;
vector <bool> s;
int n, r;

int main()
{
	ios::sync_with_stdio(false);
	s.resize(1000 * 1000);
	cin >> n >> r;
	int res = INF, x;
	for (int i = 0; i <= r; i++)
	{
		int moveNum = 0, wMove = 0, a = i, b = r;
		while (a != 0 && wMove < res && moveNum < n)
		{
			moveNum += b / a;
			wMove += b / a - 1;
			if (a == 1 && b != 1)
				wMove--;
			b %= a;
			swap(a, b);
		}
		if (b == 1 && wMove < res)
			x = i, res = wMove;
	}
	if (res == INF)
		cout << "IMPOSSIBLE\n";
	else
	{
		for (int i = n - 1; i >= 0; i--)
			if (x < r)
			{
				s[i] = 1;
				r -= x;
			}
			else
				x -= r;
		cout << res << '\n';
		if (s[1])
		{
			for (int i = 0; i < n; i++)
				cout << (s[i] ? 'B' : 'T');
		}
		else
		{
			cout << 'T';
			for (int i = 1; i < n; i++)
				cout << (s[i] ? 'T' : 'B');
		}
		cout << '\n';
	}
	return 0;
}


// In the name of God

#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

const long long INF = 1LL << 60;
vector <bool> s;
int n, r;

int main()
{
	s.resize(1000 * 1000);
	cin >> n >> r;
	long long res = INF, x;
	for (int i = 0; i <= r; i++)
	{
		int moveNum = 0, wMove = 0, a = i, b = r;
		while (a != 0)
		{
			moveNum += b / a;
			wMove += b / a - 1;
			if (a == 1 && b != 1)
				wMove--;
			b %= a;
			swap(a, b);
		}
		if (b == 1 && moveNum == n && wMove < res)
			x = i, res = wMove;
	}
	if (res == INF)
		cout << "IMPOSSIBLE\n";
	else
	{
		for (int i = n - 1; i >= 0; i--)
			if (x < r)
			{
				s[i] = 1;
				r -= x;
			}
			else
				x -= r;
		cout << res << '\n';
		ios::sync_with_stdio(false);
		if (s[1])
		{
			for (int i = 0; i < n; i++)
				cout << (s[i] ? 'B' : 'T');
		}
		else
		{
			cout << 'T';
			for (int i = 1; i < n; i++)
				cout << (s[i] ? 'T' : 'B');
		}
		cout << '\n';
	}
	return 0;
}


// In the name of God

#include <iostream>
#include <cstdio>

using namespace std;

const int INF = 1LL << 30;
bool s[1000 * 1000];
int n, r;

int main()
{
	scanf("%d%d", &n, &r);
	int res = INF, x;
	for (int i = 0; i <= r; i++)
	{
		int moveNum = 0, wMove = 0, a = i, b = r;
		while (a != 0 && wMove < res)
		{
			moveNum += b / a;
			wMove += b / a - ((a == 1 && b != 1) ? 2 : 1);
			b %= a;
			swap(a, b);
		}
		if (b == 1 && moveNum == n && wMove < res)
			x = i, res = wMove;
	}
	if (res == INF)
		puts("IMPOSSIBLE\n");
	else
	{
		for (int i = n - 1; i >= 0; i--)
			if (x < r)
			{
				s[i] = 1;
				r -= x;
			}
			else
				x -= r;
		printf("%d\n", res);
		if (s[1])
		{
			for (int i = 0; i < n; i++)
				putchar(s[i] ? 'B' : 'T');
		}
		else
		{
			putchar('T');
			for (int i = 1; i < n; i++)
				putchar(s[i] ? 'T' : 'B');
		}
		putchar('\n');
	}
	return 0;
}


// In the name of God

#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

const int INF = 1LL << 30;
vector <bool> s;
int n, r;

int main()
{
	ios::sync_with_stdio(false);
	s.resize(1000 * 1000);
	cin >> n >> r;
	int res = INF, x;
	for (int i = 0; i <= r; i++)
	{
		int moveNum = 0, wMove = 0, a = i, b = r;
		while (a != 0)
		{
			moveNum += b / a;
			wMove += b / a - 1;
			if (a == 1 && b != 1)
				wMove--;
			if (wMove >= res)
				break;
			b %= a;
			swap(a, b);
		}
		if (b == 1 && moveNum == n && wMove < res)
			x = i, res = wMove;
	}
	if (res == INF)
		cout << "IMPOSSIBLE\n";
	else
	{
		for (int i = n - 1; i >= 0; i--)
			if (x < r)
			{
				s[i] = 1;
				r -= x;
			}
			else
				x -= r;
		cout << res << '\n';
		if (s[1])
		{
			for (int i = 0; i < n; i++)
				cout << (s[i] ? 'B' : 'T');
		}
		else
		{
			cout << 'T';
			for (int i = 1; i < n; i++)
				cout << (s[i] ? 'T' : 'B');
		}
		cout << '\n';
	}
	return 0;
}


// In the name of God

#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

const int INF = 1LL << 30;
vector <bool> s;
int n, r;

int main()
{
	ios::sync_with_stdio(false);
	cin >> n >> r;
	s.resize(n);
	int res = INF, x;
	for (int i = 0; i <= r; i++)
	{
		int moveNum = 0, wMove = 0, a = i, b = r;
		while (a != 0 && wMove < res && moveNum < n)
		{
			moveNum += b / a;
			wMove += b / a - ((a == 1 && b != 1) ? 2 : 1);
			b %= a;
			swap(a, b);
		}
		if (b == 1 && moveNum == n && wMove < res)
			x = i, res = wMove;
	}
	if (res == INF)
		cout << "IMPOSSIBLE\n";
	else
	{
		for (int i = n - 1; i >= 0; i--)
			if (x < r)
			{
				s[i] = 1;
				r -= x;
			}
			else
				x %= r;
		cout << res << '\n';
		if (s[1])
		{
			for (int i = 0; i < n; i++)
				cout << (s[i] ? 'B' : 'T');
		}
		else
		{
			cout << 'T';
			for (int i = 1; i < n; i++)
				cout << (s[i] ? 'T' : 'B');
		}
		cout << '\n';
	}
	return 0;
}


// In the name of God

#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

const int INF = 1LL << 30;
vector <bool> s(1000 * 1000);
int n, r;

int main()
{
	ios::sync_with_stdio(false);
	cin >> n >> r;
	int res = INF, x;
	for (int i = 0; i <= r; i++)
	{
		int moveNum = 0, wMove = 0, a = i, b = r;
		while (a != 0 && wMove < res)
		{
			moveNum += b / a;
			wMove += b / a - ((a == 1 && b != 1) ? 2 : 1);
			b %= a;
			swap(a, b);
		}
		if (b == 1 && moveNum == n && wMove < res)
			x = i, res = wMove;
	}
	if (res == INF)
		cout << "IMPOSSIBLE\n";
	else
	{
		for (int i = n - 1; i >= 0; i--)
			if (x < r)
			{
				s[i] = 1;
				r -= x;
			}
			else
				x -= r;
		cout << res << '\n';
		if (s[1])
		{
			for (int i = 0; i < n; i++)
				cout << (s[i] ? 'B' : 'T');
		}
		else
		{
			cout << 'T';
			for (int i = 1; i < n; i++)
				cout << (s[i] ? 'T' : 'B');
		}
		cout << '\n';
	}
	return 0;
}


// In the name of God

#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

const int INF = 1LL << 30;
vector <bool> s;
int n, r;

int main()
{
	ios::sync_with_stdio(false);
	s.resize(1000 * 1000);
	cin >> n >> r;
	int res = INF, x;
	for (int i = 0; i <= r; i++)
	{
		int moveNum = 0, wMove = 0, a = i, b = r;
		while (a != 0 && wMove < res)
		{
			moveNum += b / a;
			wMove += b / a - 1;
			if (a == 1 && b != 1)
				wMove--;
			b %= a;
			swap(a, b);
		}
		if (b == 1 && moveNum == n && wMove < res)
			x = i, res = wMove;
	}
	if (res == INF)
		cout << "IMPOSSIBLE\n";
	else
	{
		for (int i = n - 1; i >= 0; i--)
			if (x < r)
			{
				s[i] = 1;
				r -= x;
			}
			else
				x -= r;
		cout << res << '\n';
		if (s[1])
		{
			for (int i = 0; i < n; i++)
				cout << (s[i] ? 'B' : 'T');
		}
		else
		{
			cout << 'T';
			for (int i = 1; i < n; i++)
				cout << (s[i] ? 'T' : 'B');
		}
		cout << '\n';
	}
	return 0;
}


// In the name of God

#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

const int INF = 1LL << 30;
vector <bool> s;
int n, r;

int main()
{
	ios::sync_with_stdio(false);
	cin >> n >> r;
	s.resize(n);
	int res = INF, x;
	for (int i = 0; i <= r; i++)
	{
		int moveNum = 0, wMove = 0, a = i, b = r;
		while (a != 0 && wMove < res)
		{
			moveNum += b / a;
			wMove += b / a - ((a == 1 && b != 1) ? 2 : 1);
			b %= a;
			swap(a, b);
		}
		if (b == 1 && moveNum == n && wMove < res)
			x = i, res = wMove;
	}
	if (res == INF)
		cout << "IMPOSSIBLE\n";
	else
	{
		for (int i = n - 1; i >= 0; i--)
			if (x < r)
			{
				s[i] = 1;
				r -= x;
			}
			else
				x -= r;
		cout << res << '\n';
		if (s[1])
		{
			for (int i = 0; i < n; i++)
				cout << (s[i] ? 'B' : 'T');
		}
		else
		{
			cout << 'T';
			for (int i = 1; i < n; i++)
				cout << (s[i] ? 'T' : 'B');
		}
		cout << '\n';
	}
	return 0;
}


// In the name of God

#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

const int INF = 1LL << 30;
vector <bool> s;
int n, r;

int main()
{
	ios::sync_with_stdio(false);
	s.resize(1000 * 1000);
	cin >> n >> r;
	int res = INF, x;
	for (int i = 0; i <= r; i++)
	{
		int moveNum = 0, wMove = 0, a = i, b = r;
		while (a != 0)
		{
			moveNum += b / a;
			wMove += b / a - 1;
			if (a == 1 && b != 1)
				wMove--;
//			if (wMove >= res)
//				break;
			b %= a;
			swap(a, b);
		}
		if (b == 1 && moveNum == n && wMove < res)
			x = i, res = wMove;
	}
	if (res == INF)
		cout << "IMPOSSIBLE\n";
	else
	{
		for (int i = n - 1; i >= 0; i--)
			if (x < r)
			{
				s[i] = 1;
				r -= x;
			}
			else
				x -= r;
		cout << res << '\n';
		if (s[1])
		{
			for (int i = 0; i < n; i++)
				cout << (s[i] ? 'B' : 'T');
		}
		else
		{
			cout << 'T';
			for (int i = 1; i < n; i++)
				cout << (s[i] ? 'T' : 'B');
		}
		cout << '\n';
	}
	return 0;
}


#include <cstdio>

int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

int n, r;

int dep(int a, int b) {
    if (a < b) return dep(b, a);
    return b ? a / b + dep(b, a % b) : 0;
}

int gao(int a, int b) {
    if (a < b) return gao(b, a);
    if (b == 1) return a / b - 1;
    return a / b - 1 + gao(b, a % b);
}

int dfs(int a, int b) {
    if (b == 1) {
        printf("T");
        for (int i = 1; i < a; ++i) {
            printf("B");
        }
        return 0;
    }
    int x = dfs(b, a % b);
    for (int i = 0; i < a/b; ++i) {
        printf(x ? "B" : "T");
    }
    return !x;
}

int main() {
    scanf("%d%d", &n, &r);
    if (n == 1 && r == 1) {
        printf("0\nT\n");
        return 0;
    }
    int ans = n+1, k;
    for (int i = 0; i < r; ++i) {
//      printf("%d %d %d", i, gcd(r, i), dep(r, i));
        if (gcd(r, i) == 1 && dep(r, i) == n) {
            int tmp = gao(r, i);
//          printf(" %d", tmp);
            if (tmp < ans) {
                ans = tmp;
                k = i;
            }
        }
//      puts("");
    }
    if (ans > n) {
        puts("IMPOSSIBLE");
    } else {
        printf("%d\n", ans-1);
        dfs(r, k);
        puts("");
    }
}