#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < (b); ++i)
#define rrep(i,a,b) for(int i = (b); i --> (a);)
#define all(v) (v).begin(),(v).end()
#define trav(x,v) for(auto &x : v)
#define sz(v) int(v.size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;

const ll md = 998244353;

int ren(int c){
	return c=='R' ? 0 : c=='G' ? 1 : 2;
}

int main(){
	cin.sync_with_stdio(0);
	cin.tie(0);

	int n;
	cin >> n;

	string s;
	cin >> s;

	vi l1(3), l2(3);
	ll ans = 1;
	trav(c, s){
		int i = ren(c);
		int j = (i+1)%3;
		int k = (i+2)%3;
		if(l2[i]){
			ans = ans * l2[i] % md,
			--l2[i];
		} else if(l1[j]){
			ans = ans * l1[j] % md;
			--l1[j];
			++l2[k];
		} else if(l1[k]){
			ans = ans * l1[k] % md;
			--l1[k];
			++l2[j];
		} else {
			++l1[i];
		}
	}
	rep(i,2,n+1) ans = ans * i % md;
	cout << ans << endl;
}
