#coding: utf-8;
import itertools
import math

def hoge(i,flag):
  s = list(flag)
  s[i] = "B"
  return "".join(s)

N = int(input())
data = input()

R=[]
G=[]
B=[]
count = 0

for i,c in enumerate(data):
  if c=="R":
    R.append(i)
    continue
  if c=="G":
    G.append(i)
    continue
  if c=="B":
    B.append(i)
    continue

temp_max = 999999999999
min_list = []
#全探索(N!^2)でやってみようか
for num,x in enumerate(itertools.permutations(G)):
  for y in itertools.permutations(B):
      for i in range(N):
        ti = R[i]+G[i]+B[i]
        if ti==temp_max:
          min_list.append(R[i]+G[i]+B[i])
        elif ti<temp_max:
          temp_max = ti
          min_list = [R[i]+G[i]+B[i]]

print((len(min_list)*math.factorial(N))%998244353)

##TLE -> temp_maxより大きいのは登録しないようにしようか