#include<bits/stdc++.h>
using namespace std;

#define ll long long int

#define pi 2*acos(0.0)
#define mod 1000000007

#define fast   ios_base::sync_with_stdio(false);cin.tie(NULL);

#define pii pair<ll,ll>

#define pb push_back

#define Bit_off(val,pos)       (val & (~(1<<pos)))
#define Bit_on(val,pos)        (val | (1<<pos))
#define Bit_toggle(val,pos)    (val ^ (1<<pos))
#define Bit_check(val,pos)     (bool)(val & (1<<pos))
#define odd_even(val)          (bool)(val & 1)
#define koita_1_ase(val)       (__builtin_popcount(val))

//ll Big_Mod(ll v1, ll p, ll md)  { ll res=1; v1=v1%md; while (p > 0){if (p & 1)res = (res * v1) % md; p =p>>1; v1 = (v1 * v1) % md;}return res;}
ll ar[500009],cr[500009],br[500009],tr[500009];
ll fx[]= {-1,1,0,0};
ll fy[]= {0,0,1,-1};


map<ll,ll>mp,mp1,mp2;
vector<ll>v[500009],v1;
string s,q;

struct evan
{
    ll l,r,w;

} st[500009];

bool com(evan a,evan b)
{
    return a.r<b.r;
}

int main()
{
    fast;
    ll a,b,c,d,e,i,j,k,x,y,z,f,g,h,n,m;

    cin>>n>>x>>s;
    for(i=0; i<n; i++)
    {
        if(s[i]=='o')
        {
            x++;
        }
        else
        {
            if(x)
            {
                x--;
            }
        }
    }
    cout<<x<<endl;
}


#include<map>
#include<ctime>
#include<cstdio>
#include<cctype>
#include<string>
#define ll long long
const ll N=1e3+10;
const ll HgS=1e9+7;
using namespace std;
ll read() {
	char c;
	ll x=0,f=1;
	while(!isdigit(c=getchar()))
		f-=2*(c=='-');
	while (isdigit(c)){
		x=x*10+(c-48)*f;
		c=getchar();
	}
	return x;
}
ll n,f,res;
ll fib(ll n){
	ll a=0,b=1,c=0;
	for(ll i=1;i<=n;++i){
		c=(a+b)%HgS;
		a=b;
		b=c;
	}
	return a;
}
int main() {
	#ifndef ONLINE_JUDGE
	freopen("D.in","r",stdin);
	freopen("D.out","w",stdout);
	#endif
	clock_t t1=clock();
	//--------
	n=read();
	for(int i=0;i<4;++i){
		char c;
		while(!isalpha(c=getchar()));
		f<<=1;
		f|=(c=='B');
	}
	switch(f){
		case 0:
		case 1:
		case 2:
		case 3:
		case 5:
		case 7:
		case 13:
		case 15:
			res=1;
			break;
		case 4:
		case 10:
		case 11:
		case 12:
			res=1;
			for(int i=4;i<=n;++i){
				res<<=1;
				res%=HgS;
			}
			break;
		default:
			res=fib(n-1);
			break;
	}
	printf("%lld",res);
	//--------
	clock_t t2=clock();
	fprintf(stderr,"time:%0.3lfs",1.0*(t2-t1)/CLOCKS_PER_SEC);
	return 0;
}