#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x)
{
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)){if(c=='-')f=-1; c=getchar();}
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int N=2e5+10,mod=1e9+7;
char str[N];
int n;
int main() {
	rd(n);
	scanf("%s",str+1);
	int cnt=0,ans=1;
	int cur=0;
	for(int i=1;i<=2*n;++i) {
		int c=str[i]=='B';
		if(c!=cur) cnt++;
		else ans=ans*(ll)cnt%mod,cnt--;
		cur^=1;
	}
	if(cnt!=0) ans=0;
	for(int i=1;i<=n;++i) ans=ans*(ll)i%mod;
	printf("%d",ans);
	return 0;
}
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
ll const INF = 1LL << 60;
ll const MAX_N = 510000;
ll const MOD = 1000000007;

// 約数の列挙 O(√n)
vector<ll> divisor(ll n) {
    vector<ll> res;

    for (ll i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            res.push_back(i);
            if (i != n / i) res.push_back(n / i);
        }
    }

    return res;
}

int main() {
    ll N, M;
    cin >> N >> M;

    vector<ll> divs = divisor(M);
    ll ans = 0;
    for (ll i = divs.size() - 1; i >= 0; i--) {
        if (M % divs[i] == 0) {
            ll sub_m = M / divs[i];
            if (sub_m >= N) {
                ans = max(ans, divs[i]);
            }
        }
    }

    cout << ans << endl;

    return 0;
}
