#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=1e5+7;
const LL MOD=1e9+7;
LL rec[maxn];


int main()
{
	int len;cin >> len;
	string arr;
	LL ans=1;
	rec[3]=1;rec[4]=2;rec[2]==1;
	for(int i=0;i<4;++i)
	{
		char tem; cin >> tem; arr+=tem;
	}
	if(len<4||arr[0]=='A'&&arr[1]=='A'||arr[1]=='B'&&arr[3]=='B'){cout << 1;return 0;}
	for(int i=5;i<=len;i++)
		rec[i]=(rec[i-1]+rec[i-2])%MOD;
	for(int i=4;i<=len;++i)
		ans=(ans<<1)%MOD;
	if(arr=="BAAB"||arr=="BBBA"||arr=="ABBA"||arr=="BAAA")
	{
		cout <<rec[len]; return 0;
	}
	else
		cout << ans;
	return 0;


	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll t,i,endi=0,starti=0;
    string s;
    cin>>s;
    string ss;
    for(i=s.size()-1;i>=0;i--)
    {
        ss.push_back(s[i]);
    }
    if(ss==s)cout<<"Yes"<<endl;
    else{
    ss={};
    //if()
    for(i=s.size()-1;i>=0;i--)
    {
        if(s[i]!='0')break;
        else endi++;
    }
    for(i=0;i<s.size();i++)
    {
        if(s[i]!='0')break;
        else starti++;
    }
    string xs;
    if(endi==0)cout<<"No"<<endl;
    else
    {
        if(endi>starti)
        {
            for(i=starti;i!=endi;i++)
            {
              xs.push_back('0');
            }
            xs+=s;
            for(i=xs.size()-1;i>=0;i--)
            {
                ss.push_back(xs[i]);
            }
            if(ss==xs)cout<<"Yes"<<endl;
            else cout<<"No"<<endl;
        }
        else cout<<"No"<<endl;

    }

    }
}
