Nothing is eternal in the world, Kostya understood it on the 7-th of January when he saw partially dead four-color garland.

Now he has a goal to replace dead light bulbs, however he doesn't know how many light bulbs for each color are required. It is guaranteed that for each of four colors at least one light is working.

It is known that the garland contains light bulbs of four colors: red, blue, yellow and green. The garland is made as follows: if you take any four consecutive light bulbs then there will not be light bulbs with the same color among them. For example, the garland can look like "RYBGRYBGRY", "YBGRYBGRYBG", "BGRYB", but can not look like "BGRYG", "YBGRYBYGR" or "BGYBGY". Letters denote colors: 'R' — red, 'B' — blue, 'Y' — yellow, 'G' — green.

Using the information that for each color at least one light bulb still works count the number of dead light bulbs of each four colors.


-----Input-----

The first and the only line contains the string s (4 ≤ |s| ≤ 100), which describes the garland, the i-th symbol of which describes the color of the i-th light bulb in the order from the beginning of garland:   'R' — the light bulb is red,  'B' — the light bulb is blue,  'Y' — the light bulb is yellow,  'G' — the light bulb is green,  '!' — the light bulb is dead. 

The string s can not contain other symbols except those five which were described. 

It is guaranteed that in the given string at least once there is each of four letters 'R', 'B', 'Y' and 'G'. 

It is guaranteed that the string s is correct garland with some blown light bulbs, it means that for example the line "GRBY!!!B" can not be in the input data. 


-----Output-----

In the only line print four integers k_{r}, k_{b}, k_{y}, k_{g} — the number of dead light bulbs of red, blue, yellow and green colors accordingly.


-----Examples-----
Input
RYBGRYBGR

Output
0 0 0 0
Input
!RGYB

Output
0 1 0 0
Input
!!!!YGRB

Output
1 1 1 1
Input
!GB!RG!Y!

Output
2 1 1 0


-----Note-----

In the first example there are no dead light bulbs.

In the second example it is obvious that one blue bulb is blown, because it could not be light bulbs of other colors on its place according to the statements.

Source: codeforces | Difficulty: EASY
Tags: Number theory

Implementation

Complete search


Solutions:
s = list(input().strip())
used = 10000 * [0]
tested_chars = {'R': 0, 'G': 0, 'Y': 0, 'B': 0}
ans = {'R': 0, 'G': 0, 'Y': 0, 'B': 0}

def dfs(c, position):
	if position < 0:
		return
	if position >= len(s):
		return
	if used[position] == 1:
		return
	used[position] = 1
	if s[position] == '!':
		s[position] = c
		ans[c] = ans[c] + 1
	prev = position - 4
	next = position + 4
	dfs(c, next)
	dfs(c, prev)
for i in range(len(s)):
	if s[i] == '!':
		continue
	if tested_chars[s[i]] == 0:
		dfs(s[i], i)
		tested_chars[s[i]] = 1
print(ans['R'], ' ', ans['B'], ' ', ans['Y'], ' ', ans['G'], sep='')


s = input()
a = ['0', '0', '0', '0']
b = [0, 0, 0, 0]
c = ['R', 'B', 'Y', 'G']
d = ['R', 'B', 'Y', 'G']
l = len(s)
for i in range(l):
	if s[i] in c:
		a[i % 4] = c.pop(c.index(s[i]))
for i in range(l):
	if s[i] == '!':
		b[i % 4] += 1
for i in d:
	print(b[a.index(i)], end=' ')


s = [ch for ch in input()]
n = len(s)
d = {'R': True, 'B': True, 'Y': True, 'G': True}
a = {}
while len(d) > 0:
	for i in range(0, n):
		if s[i] != '!' and d.get(s[i]):
			count = 0
			for j in range(i % 4, n, 4):
				if s[j] == '!':
					count += 1
			a[s[i]] = count
			del d[s[i]]
			break
print(a['R'], a['B'], a['Y'], a['G'])


s = list(input())
d = {'R': -1, 'Y': -1, 'G': -1, 'B': -1}
j = 0
for i in s:
	if i != '!':
		d[i] = j % 4
	j += 1
_d = {}
for key in d:
	_d[d[key]] = key
j = 0
l = [0, 0, 0, 0]
for i in range(len(s)):
	if s[i] == '!':
		try:
			key = _d[j % 4]
		except:
			key = _d[-1]
		if key == 'R':
			l[0] += 1
		elif key == 'B':
			l[1] += 1
		elif key == 'Y':
			l[2] += 1
		elif key == 'G':
			l[3] += 1
	j += 1
for i in l:
	print(i, end=' ')


a = [0 for i in range(4)]
p = [0 for i in range(4)]
b = input()
c = '!'
i = 0
for k in range(4):
	while c == '!':
		c = b[k + i * 4]
		i += 1
	p[k] = c
	c = '!'
	i = 0
for k in range(len(b)):
	if b[k] == '!':
		a[k % 4] += 1
for g in ['R', 'B', 'Y', 'G']:
	for k in range(4):
		if p[k] == g:
			print(a[k], end=' ')


s = input()
i_r = s.index('R') % 4
i_y = s.index('Y') % 4
i_b = s.index('B') % 4
i_g = s.index('G') % 4
k_r = sum((c == '!' for c in s[i_r::4]))
k_b = sum((c == '!' for c in s[i_b::4]))
k_y = sum((c == '!' for c in s[i_y::4]))
k_g = sum((c == '!' for c in s[i_g::4]))
print(k_r, k_b, k_y, k_g)


s = input()
n = len(s)
arr = {'R': 0, 'B': 0, 'Y': 0, 'G': 0}
for i in range(4):
	j = i
	count = 0
	while j < n:
		if s[j] == '!':
			count += 1
		else:
			chr = s[j]
		j += 4
	arr[chr] = count
for j in list(arr.values()):
	print(j, end=' ')


s = input()
k = {'R': 0, 'Y': 0, 'B': 0, 'G': 0}
a = [''] * 4
for i in range(len(s)):
	if s[i] != '!' and a[i % 4] == '':
		a[i % 4] = s[i]
for i in range(len(s)):
	if s[i] == '!':
		k[a[i % 4]] += 1
print(k['R'], k['B'], k['Y'], k['G'])


s = input()
rbyg_index = [''] * 4
count = [0] * 4
for (i, c) in enumerate(s):
	if c == '!':
		count[i % 4] += 1
	else:
		rbyg_index[i % 4] = c
ans = []
for c in 'RBYG':
	if not c in rbyg_index:
		i = rbyg_index.index('')
		rbyg_index[i] = c
	ans.append(count[rbyg_index.index(c)])
print(*ans)


s = input().strip()
arr = []
k = 0
while True:
	if s[k] == '!':
		k += 4
	else:
		arr.append(s[k])
		break
k = 1
while True:
	if s[k] == '!':
		k += 4
	else:
		arr.append(s[k])
		break
k = 2
while True:
	if s[k] == '!':
		k += 4
	else:
		arr.append(s[k])
		break
k = 3
while True:
	if s[k] == '!':
		k += 4
	else:
		arr.append(s[k])
		break
dict = {'R': 0, 'B': 0, 'Y': 0, 'G': 0}
for i in range(len(s)):
	if s[i] == '!':
		dict[arr[i % 4]] += 1
print(dict['R'], ' ', dict['B'], ' ', dict['Y'], ' ', dict['G'])


s = input()
l = list(s)
s2 = [0, 0, 0, 0]
for i in range(len(l)):
	if l[i] != '!':
		if (i + 1) % 4 == 1:
			s2[0] = l[i]
		elif (i + 1) % 4 == 2:
			s2[1] = l[i]
		elif (i + 1) % 4 == 3:
			s2[2] = l[i]
		elif (i + 1) % 4 == 0:
			s2[3] = l[i]
ans = ''.join(s2)
ans1 = ans * (len(s) // 4) + ans[:len(s) % 4]
print(ans1.count('R') - s.count('R'), ans1.count('B') - s.count('B'), ans1.count('Y') - s.count('Y'), ans1.count('G') - s.count('G'))


def assign(n, i):
	for e in range(i, len(n), 4):
		if n[e] == '!':
			continue
		else:
			return n[e]
n = list(input())
l2 = [0] * 4
for i in range(4):
	l2[i] = assign(n, i)
di = {l2[0]: 0, l2[1]: 0, l2[2]: 0, l2[3]: 0}
for i in range(len(n)):
	if n[i] == '!':
		di[l2[i % 4]] += 1
print(di['R'], di['B'], di['Y'], di['G'])


s = input()
(r, y, g, b) = [s.index(i) % 4 for i in 'RYGB']
(d, a, t) = ({r: 'R', y: 'Y', g: 'G', b: 'B'}, {'R': 0, 'Y': 0, 'G': 0, 'B': 0}, [])
for x in range(len(s)):
	if s[x] == '!':
		a[d[x % 4]] += 1
for y in 'RBYG':
	print(a[y], end=' ')


given = input()
abcd = [-1, -1, -1, -1]
for i in range(4):
	for n in range(len(given)):
		if 4 * n + i > len(given) - 1:
			break
		if given[4 * n + i] == 'R':
			abcd[i] = 'R'
			break
		elif given[4 * n + i] == 'B':
			abcd[i] = 'B'
			break
		elif given[4 * n + i] == 'Y':
			abcd[i] = 'Y'
			break
		elif given[4 * n + i] == 'G':
			abcd[i] = 'G'
			break
ABCD = [0, 0, 0, 0]
for i in range(len(given)):
	if given[i] == '!':
		pos = i % 4
		ABCD[pos] += 1
var = 'RBYG'
issueWith = -1
issueVal = -1
for i in var:
	if i not in abcd:
		issueWith = i
		break
if issueWith != -1:
	issueVal = abcd.index(-1)
	abcd[issueVal] = issueWith
val = abcd.index('R')
r = ABCD[val]
val = abcd.index('B')
b = ABCD[val]
val = abcd.index('Y')
y = ABCD[val]
val = abcd.index('G')
g = ABCD[val]
print(str(r) + ' ' + str(b) + ' ' + str(y) + ' ' + str(g))


s = input()
d = {}
c = [0, 0, 0, 0]
for (i, item) in enumerate(s):
	if item == '!':
		c[i % 4] += 1
	else:
		d[item] = i % 4
for i in 'RBYG':
	print(c[d[i]])


s = input()
n = len(s)
color = ['-', '-', '-', '-']
ans = {'R': 0, 'B': 0, 'G': 0, 'Y': 0}
for i in range(n):
	if s[i] != '!':
		color[i % 4] = s[i]
for i in range(n):
	if s[i] == '!':
		ans[color[i % 4]] += 1
print(ans['R'], ans['B'], ans['Y'], ans['G'])


line = str(input())
refer_n = [0] * 4
refer_c = [''] * 4
size = len(line)
for i in range(size):
	if line[i] == '!':
		refer_n[i % 4] += 1
	else:
		refer_c[i % 4] = line[i]
print(' '.join([str(refer_n[refer_c.index(it)]) for it in 'RBYG']))


s = [x for x in input()]
n = len(s)
need = 4
p = {}
for i in range(n):
	if s[i] != '!':
		p[i % 4] = s[i]
c = {'R': 0, 'B': 0, 'Y': 0, 'G': 0}
for i in range(n):
	if s[i] == '!':
		c[p[i % 4]] += 1
print(c['R'], c['B'], c['Y'], c['G'])


import os
import sys
from io import BytesIO, IOBase
import math

def main():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(i)
			n = n / i
	if n > 2:
		l.append(int(n))
	return l

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def maxPrimeFactors(n):
	maxPrime = -1
	while n % 2 == 0:
		maxPrime = 2
		n >>= 1
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			maxPrime = i
			n = n / i
	if n > 2:
		maxPrime = n
	return int(maxPrime)

def countcon(s, i):
	c = 0
	ch = s[i]
	for i in range(i, len(s)):
		if s[i] == ch:
			c += 1
		else:
			break
	return c
s = input()
rbyg = [s.index('R') % 4, s.index('B') % 4, s.index('Y') % 4, s.index('G') % 4]
exc = [0, 0, 0, 0]
for i in range(0, len(s)):
	if s[i] == '!':
		exc[i % 4] += 1
for i in range(0, 4):
	print(exc[rbyg[i]], end=' ')


s = input()
r = s.index('R')
b = s.index('B')
y = s.index('Y')
g = s.index('G')
r = r % 4
b = b % 4
y = y % 4
g = g % 4
R = 0
B = 0
Y = 0
G = 0
for i in range(0, len(s)):
	if s[i] == '!':
		if i % 4 == r:
			R += 1
		elif i % 4 == b:
			B += 1
		if i % 4 == y:
			Y += 1
		if i % 4 == g:
			G += 1
print(R, B, Y, G)


cnt = lambda s, x: s.count(x)
ii = lambda : int(input())
si = lambda : input()
f = lambda : map(int, input().split())
dgl = lambda : list(map(int, input()))
il = lambda : list(map(int, input().split()))
s = si()
d = {}
lc = [0, 0, 0, 0]
for i in range(len(s)):
	if s[i] != '!':
		d[s[i]] = i % 4
for i in range(len(s)):
	if s[i] == '!':
		lc[i % 4] += 1
for i in 'RBYG':
	print(lc[d[i]], end=' ')


str = input()
pos = [0] * 4
kr = kb = ky = kg = 0
for i in range(0, len(str), 4):
	if str[i] != '!':
		pos[0] = str[i]
		break
for i in range(1, len(str), 4):
	if str[i] != '!':
		pos[1] = str[i]
		break
for i in range(2, len(str), 4):
	if str[i] != '!':
		pos[2] = str[i]
		break
for i in range(3, len(str), 4):
	if str[i] != '!':
		pos[3] = str[i]
		break
for i in range(0, len(str)):
	if str[i] == '!':
		l = pos[i % 4]
		if l == 'R':
			kr = kr + 1
		elif l == 'Y':
			ky = ky + 1
		elif l == 'B':
			kb = kb + 1
		else:
			kg = kg + 1
print(kr, kb, ky, kg)


n = input()
first = {}
for i in range(len(n)):
	if n[i] != '!':
		first[i % 4] = n[i]
value = {'R': 0, 'B': 0, 'Y': 0, 'G': 0}
for j in range(len(n)):
	if n[j] == '!':
		value[first[j % 4]] += 1
print(value['R'], value['B'], value['Y'], value['G'])


S = input()
rda = [0] * 4
for (i, c) in enumerate(S):
	if c != '!':
		rda[i % 4] = ord(c)
gb = [0] * 256
for (i, c) in enumerate(S):
	if c == '!':
		gb[rda[i % 4]] += 1
ans = [gb[ord('R')], gb[ord('B')], gb[ord('Y')], gb[ord('G')]]
print(' '.join(map(str, ans)))


m = input()
l = ['a', 'b', 'c', 'd']
i = 0
for i in range(0, len(m)):
	if m[i] != '!' and m[i] not in l:
		l[i % 4] = m[i]
cr = 0
cb = 0
cy = 0
cg = 0
for i in range(0, len(m)):
	if m[i] == '!':
		color = l[i % 4]
		if color == 'R':
			cr += 1
		elif color == 'Y':
			cy += 1
		elif color == 'G':
			cg += 1
		else:
			cb += 1
print(cr, cb, cy, cg)


s = input()
trr = [0 for i in range(4)]
prr = ['a', 'b', 'c', 'd']
for i in range(len(s)):
	if s[i] != '!':
		prr[i % 4] = s[i]
	else:
		trr[i % 4] += 1
krr = [0, 0, 0, 0]
for i in range(4):
	if prr[i] == 'R':
		krr[0] = trr[i]
	if prr[i] == 'B':
		krr[1] = trr[i]
	if prr[i] == 'Y':
		krr[2] = trr[i]
	if prr[i] == 'G':
		krr[3] = trr[i]
print(krr[0], krr[1], krr[2], krr[3])


s = input()
r_i = s.index('R') % 4
b_i = s.index('B') % 4
y_i = s.index('Y') % 4
g_i = s.index('G') % 4
dead = [0, 0, 0, 0]
for (idx, c) in enumerate(s):
	if c != '!':
		continue
	if idx % 4 == r_i:
		dead[0] += 1
	if idx % 4 == b_i:
		dead[1] += 1
	if idx % 4 == y_i:
		dead[2] += 1
	if idx % 4 == g_i:
		dead[3] += 1
print(*dead)


s = input()
n = len(s)
res = [0, 0, 0, 0]
for i in range(len(s)):
	if s[i] == 'R':
		for j in range(i % 4, n, 4):
			if s[j] == '!':
				res[0] += 1
		break
for i in range(len(s)):
	if s[i] == 'B':
		for j in range(i % 4, n, 4):
			if s[j] == '!':
				res[1] += 1
		break
for i in range(len(s)):
	if s[i] == 'Y':
		for j in range(i % 4, n, 4):
			if s[j] == '!':
				res[2] += 1
		break
for i in range(len(s)):
	if s[i] == 'G':
		for j in range(i % 4, n, 4):
			if s[j] == '!':
				res[3] += 1
		break
print(' '.join([str(z) for z in res]))


(s, v) = (input(), [])
for (i, ch) in enumerate('RBYG'):
	p = s.find(ch) % 4
	v.append(len(s[p::4]) - s.count(ch))
print(' '.join(map(str, v)))


s = str(input())
for i in (s.index(c) % 4 for c in 'RBYG'):
	print(s[i::4].count('!'), end=' ')


n = input()
l = len(n)
r = 0
y = 0
b = 0
g = 0
R = 0
Y = 0
B = 0
G = 0
for i in range(l):
	if n[i] is 'R':
		r = i % 4
	elif n[i] is 'Y':
		y = i % 4
	elif n[i] is 'B':
		b = i % 4
	elif n[i] is 'G':
		g = i % 4
for i in range(l):
	if n[i] is '!':
		j = i % 4
		if j is r:
			R += 1
		elif j is y:
			Y += 1
		elif j is b:
			B += 1
		elif j is g:
			G += 1
print(R, B, Y, G)


strings = input()
red = 0
blue = 0
yellow = 0
green = 0
count = 0
key = ['', '', '', '']
for x in range(0, len(strings)):
	if strings[x] != '!':
		temporary = (x + 1) % 4
		if temporary == 0:
			temporary = 4
		if count != 4:
			key[temporary - 1] = strings[x]
		else:
			break
for x in range(0, len(strings)):
	if strings[x] == '!':
		if key[x % 4] == 'B':
			blue += 1
		if key[x % 4] == 'R':
			red += 1
		if key[x % 4] == 'Y':
			yellow += 1
		if key[x % 4] == 'G':
			green += 1
print(red, blue, yellow, green)


garland = input()
n = len(garland)
res = dict()
res['R'] = 0
res['B'] = 0
res['Y'] = 0
res['G'] = 0
dead = set()
reminders = [''] * 4
for i in range(n):
	if garland[i] != '!':
		reminders[i % 4] = garland[i]
	elif reminders[i % 4] != '':
		res[reminders[i % 4]] += 1
	else:
		dead.add(i)
for i in dead:
	res[reminders[i % 4]] += 1
print(str(res['R']) + ' ' + str(res['B']) + ' ' + str(res['Y']) + ' ' + str(res['G']))


s = input()
a = [s[j] for j in range(len(s))]
col = ['R', 'B', 'Y', 'G']
ans = [-1, -1, -1, -1]
for i in range(4):
	j = i
	curr = 0
	color = -1
	while j < len(a):
		if a[j] == '!':
			curr += 1
		else:
			for k in range(4):
				if a[j] == col[k]:
					color = k
		j += 4
	if color != -1:
		ans[color] = curr
print(ans[0], ans[1], ans[2], ans[3])


s = input()
mp = [0, 0, 0, 0]
for i in range(0, len(s)):
	m = i % 4
	if s[i] == 'R':
		r = m
	if s[i] == 'B':
		b = m
	if s[i] == 'Y':
		y = m
	if s[i] == 'G':
		g = m
	if s[i] == '!':
		mp[m] = mp[m] + 1
print(mp[r], mp[b], mp[y], mp[g])


from collections import Counter
c = Counter()
s = input()
n = len(s)
a = ['!', '!', '!', '!']
(R, Y, G, B) = (0, 0, 0, 0)
for i in range(n):
	if s[i] != '!':
		a[i % 4] = s[i]
for i in range(n):
	if s[i] == '!':
		c[a[i % 4]] += 1
print(c['R'], c['B'], c['Y'], c['G'])


bulbs = input()
R = 0
B = 0
Y = 0
G = 0
for i in range(len(bulbs)):
	if bulbs[i] == '!':
		for s in range(i % 4, len(bulbs), 4):
			if bulbs[s] != '!':
				if bulbs[s] == 'R':
					R += 1
				elif bulbs[s] == 'B':
					B += 1
				elif bulbs[s] == 'Y':
					Y += 1
				elif bulbs[s] == 'G':
					G += 1
				break
print(R, B, Y, G)


def main():
	from collections import Counter
	import re
	try:
		while True:
			s = input()
			d = Counter()
			for i in range(4):
				t = s[i::4]
				d[re.search('[^!]', t).group()] = t.count('!')
			print(d['R'], d['B'], d['Y'], d['G'])
	except EOFError:
		pass
main()


s = input()
color = [0, 0, 0, 0]
broken = [0, 0, 0, 0]
for i in ('R', 'B', 'Y', 'G'):
	k = 0
	while s[k] != i:
		k += 1
	color[k % 4] = i
for i in range(len(s)):
	if s[i] == '!':
		broken[i % 4] += 1

def func1(N):
	i = 0
	while color[i] != N:
		i += 1
	print(broken[i])
for i in ('R', 'B', 'Y', 'G'):
	func1(i)


s = input()
si = enumerate(s)
s0 = [k for (i, k) in enumerate(s) if i % 4 == 0]
s1 = [k for (i, k) in enumerate(s) if i % 4 == 1]
s2 = [k for (i, k) in enumerate(s) if i % 4 == 2]
s3 = [k for (i, k) in enumerate(s) if i % 4 == 3]

def getIndexOfChar(c):
	if c in s0:
		return 0
	elif c in s1:
		return 1
	elif c in s2:
		return 2
	elif c in s3:
		return 3
	return -1
ri = getIndexOfChar('R')
bi = getIndexOfChar('B')
yi = getIndexOfChar('Y')
gi = getIndexOfChar('G')

def missingIndex(a, b, c):
	arr = [a, b, c]
	if 0 not in arr:
		return 0
	elif 1 not in arr:
		return 1
	elif 2 not in arr:
		return 2
	elif 3 not in arr:
		return 3
	return -1
if ri == -1:
	ri = missingIndex(bi, yi, gi)
elif bi == -1:
	bi = missingIndex(ri, yi, gi)
elif yi == -1:
	yi = missingIndex(ri, bi, gi)
elif gi == -1:
	gi = missingIndex(ri, yi, bi)

def getArray(i):
	if i == 0:
		return s0
	elif i == 1:
		return s1
	elif i == 2:
		return s2
	elif i == 3:
		return s3
r = getArray(ri)
b = getArray(bi)
y = getArray(yi)
g = getArray(gi)
rc = r.count('!')
bc = b.count('!')
yc = y.count('!')
gc = g.count('!')
print('{} {} {} {}'.format(rc, bc, yc, gc))


def p(x, y):
	global s
	for i in range(x, len(s), 4):
		if s[i] == '!':
			y += 1
	return y
s = input()
(R, B, Y, G) = (s.find('R') % 4, s.find('B') % 4, s.find('Y') % 4, s.find('G') % 4)
(r, b, y, g) = (0, 0, 0, 0)
r += p(R, r)
b += p(B, b)
y += p(Y, y)
g += p(G, g)
print(r, b, y, g)


data = list(input())
ind = [0, 0, 0, 0]
out = [0, 0, 0, 0]
for i in range(len(data)):
	if data[i] == 'R':
		ind[0] = i % 4
	elif data[i] == 'B':
		ind[1] = i % 4
	elif data[i] == 'Y':
		ind[2] = i % 4
	elif data[i] == 'G':
		ind[3] = i % 4
for i in range(len(data)):
	if data[i] == '!':
		for g in range(4):
			if i % 4 == ind[g]:
				out[g] += 1
print(*out)


x = input()
q = []
w = []
e = []
r = []
d = dict()
if '!' not in x:
	print(0, 0, 0, 0, sep=' ')
else:
	for i in range(0, len(x), 4):
		q.append(x[i])
	for i in range(1, len(x), 4):
		w.append(x[i])
	for i in range(2, len(x), 4):
		e.append(x[i])
	for i in range(3, len(x), 4):
		r.append(x[i])
	d[max(q)] = q.count('!')
	d[max(w)] = w.count('!')
	d[max(e)] = e.count('!')
	d[max(r)] = r.count('!')
	print(d['R'], d['B'], d['Y'], d['G'])


s = input()
r = s.find('R') % 4
b = s.find('B') % 4
y = s.find('Y') % 4
g = s.find('G') % 4
ans = [0] * 4
for i in range(len(s)):
	if s[i] == '!':
		ans[i % 4] += 1
print(ans[r], ans[b], ans[y], ans[g])


text = list(input())
ans = [0] * 4
orig = ['R', 'B', 'Y', 'G']
for i in range(4):
	ind = text.index(orig[i])
	for j in range(len(text)):
		if j % 4 == ind % 4 and text[j] == '!':
			ans[i] += 1
print(*ans)


s = input()
t = [0, 0, 0, 0]
k = 0
for i in s:
	if i != '!' and i not in t:
		t[k] = i
	if k == 3:
		k = 0
	else:
		k += 1
k = 0
b = [0, 0, 0, 0]
for i in s:
	if i != t[k]:
		b[k] += 1
	if k == 3:
		k = 0
	else:
		k += 1
a = 1
k = 1
while True:
	if t[k] == 'R' and a == 1:
		print(b[k], end=' ')
		a += 1
	if t[k] == 'B' and a == 2:
		print(b[k], end=' ')
		a += 1
	if t[k] == 'Y' and a == 3:
		print(b[k], end=' ')
		a += 1
	if t[k] == 'G' and a == 4:
		print(b[k], end=' ')
		break
	if k == 3:
		k = 0
	else:
		k += 1


s = input()
r = 0
while s[r] != 'R':
	r += 1
b = 0
while s[b] != 'B':
	b += 1
y = 0
while s[y] != 'Y':
	y += 1
g = 0
while s[g] != 'G':
	g += 1
pattern = ['p', 'p', 'p', 'p']
pattern[r % 4] = 'R'
pattern[b % 4] = 'B'
pattern[y % 4] = 'Y'
pattern[g % 4] = 'G'
pattern = ''.join(pattern)
defect = {'R': 0, 'B': 0, 'Y': 0, 'G': 0}
while len(s) >= 4:
	k = s[:4]
	for i in range(4):
		if pattern[i] != k[i]:
			defect[pattern[i]] += 1
	s = s[4:]
for i in range(len(s)):
	if pattern[i] != s[i]:
		defect[pattern[i]] += 1
for each in defect:
	print(defect[each], end=' ')


p = input()
di = {'R': 0, 'B': 0, 'Y': 0, 'G': 0}
s1 = [0, 0, 0, 0]
for i in range(0, len(p)):
	if p[i] == '!' and i % 4 == 0:
		s1[0] += 1
	elif p[i] == '!' and i % 4 == 1:
		s1[1] += 1
	elif p[i] == '!' and i % 4 == 2:
		s1[2] += 1
	elif p[i] == '!' and i % 4 == 3:
		s1[3] += 1
print(s1[p.index('R') % 4], end=' ')
print(s1[p.index('B') % 4], end=' ')
print(s1[p.index('Y') % 4], end=' ')
print(s1[p.index('G') % 4], end=' ')


import sys
import os

def changeStdioToFile():
	path = os.path.dirname(os.path.abspath(__file__))
	sys.stdin = open(f'{path}/input.txt', 'r')
	sys.stdout = open(f'{path}/output.txt', 'w')
t = 1
for _ in range(t):
	bulbList = input()
	n = len(bulbList)
	kaputBulb = {'R': 0, 'G': 0, 'B': 0, 'Y': 0}
	colors = ('R', 'G', 'B', 'Y')
	for color in colors:
		pos = bulbList.find(color)
		for i in range(4, max(pos - 0, n - pos) + 1, 4):
			if pos - i >= 0 and bulbList[pos - i] == '!':
				bulbList = bulbList[:pos - i] + color + bulbList[pos - i + 1:]
				kaputBulb[color] += 1
			if pos + i < n and bulbList[pos + i] == '!':
				bulbList = bulbList[:pos + i] + color + bulbList[pos + i + 1:]
				kaputBulb[color] += 1
	print(kaputBulb['R'], kaputBulb['B'], kaputBulb['Y'], kaputBulb['G'])


s = input()
d = {}
n = len(s)
for i in range(n):
	if s[i] != '!':
		d[i % 4] = s[i]
l = {'R': 0, 'B': 0, 'Y': 0, 'G': 0}
for i in range(n):
	if s[i] == '!':
		l[d[i % 4]] += 1
print(*list(l.values()))


def function1(a):
	n = len(a)
	rbyg = {'R': 0, 'B': 0, 'Y': 0, 'G': 0}
	for i in range(4):
		na = 0
		ni = 0
		for j in range(i, n, 4):
			if a[j] == '!':
				na += 1
			else:
				ni = a[j]
		rbyg[ni] = na
	return str(rbyg['R']) + ' ' + str(rbyg['B']) + ' ' + str(rbyg['Y']) + ' ' + str(rbyg['G'])

def main():
	a = input()
	print(function1(a))
main()


s = input()
n = len(s)
for i in range(n):
	if s[i] == 'R':
		if i % 4 == 0:
			k1 = 'R'
		elif i % 4 == 1:
			k2 = 'R'
		elif i % 4 == 2:
			k3 = 'R'
		else:
			k4 = 'R'
	elif s[i] == 'B':
		if i % 4 == 0:
			k1 = 'B'
		elif i % 4 == 1:
			k2 = 'B'
		elif i % 4 == 2:
			k3 = 'B'
		else:
			k4 = 'B'
	if s[i] == 'Y':
		if i % 4 == 0:
			k1 = 'Y'
		elif i % 4 == 1:
			k2 = 'Y'
		elif i % 4 == 2:
			k3 = 'Y'
		else:
			k4 = 'Y'
	if s[i] == 'G':
		if i % 4 == 0:
			k1 = 'G'
		elif i % 4 == 1:
			k2 = 'G'
		elif i % 4 == 2:
			k3 = 'G'
		else:
			k4 = 'G'
t1 = 0
t2 = 0
t3 = 0
t4 = 0
for i in range(n):
	if s[i] == '!':
		if i % 4 == 0:
			if k1 == 'R':
				t1 += 1
			if k1 == 'B':
				t2 += 1
			if k1 == 'Y':
				t3 += 1
			if k1 == 'G':
				t4 += 1
		elif i % 4 == 1:
			if k2 == 'R':
				t1 += 1
			if k2 == 'B':
				t2 += 1
			if k2 == 'Y':
				t3 += 1
			if k2 == 'G':
				t4 += 1
		elif i % 4 == 2:
			if k3 == 'R':
				t1 += 1
			if k3 == 'B':
				t2 += 1
			if k3 == 'Y':
				t3 += 1
			if k3 == 'G':
				t4 += 1
		else:
			if k4 == 'R':
				t1 += 1
			if k4 == 'B':
				t2 += 1
			if k4 == 'Y':
				t3 += 1
			if k4 == 'G':
				t4 += 1
print(t1, t2, t3, t4)


x = input()
a = x[x.index('R') % 4::4]
b = x[x.index('B') % 4::4]
c = x[x.index('Y') % 4::4]
d = x[x.index('G') % 4::4]
print(a.count('!'), b.count('!'), c.count('!'), d.count('!'))


from sys import stdin, stdout
s = list(stdin.readline().strip())
cnt = [0, 0, 0, 0]
n = len(s)
for i in range(n):
	if s[i] == 'R':
		for j in range(i + 4, n, 4):
			if s[j] == '!':
				s[j] = 'R'
				cnt[0] += 1
		for j in range(i - 4, -1, -4):
			if s[j] == '!':
				s[j] = 'R'
				cnt[0] += 1
	if s[i] == 'B':
		for j in range(i + 4, n, 4):
			if s[j] == '!':
				s[j] = 'B'
				cnt[1] += 1
		for j in range(i - 4, -1, -4):
			if s[j] == '!':
				s[j] = 'B'
				cnt[1] += 1
	if s[i] == 'Y':
		for j in range(i + 4, n, 4):
			if s[j] == '!':
				s[j] = 'Y'
				cnt[2] += 1
		for j in range(i - 4, -1, -4):
			if s[j] == '!':
				s[j] = 'Y'
				cnt[2] += 1
	if s[i] == 'G':
		for j in range(i + 4, n, 4):
			if s[j] == '!':
				s[j] = 'G'
				cnt[3] += 1
		for j in range(i - 4, -1, -4):
			if s[j] == '!':
				s[j] = 'G'
				cnt[3] += 1
stdout.write(' '.join(list(map(str, cnt))))


s = input()
for i in range(len(s)):
	if s[i] == 'B':
		b = i % 4
	elif s[i] == 'Y':
		y = i % 4
	elif s[i] == 'R':
		r = i % 4
	elif s[i] == 'G':
		g = i % 4
b_ans = 0
y_ans = 0
r_ans = 0
g_ans = 0
for i in range(len(s)):
	if s[i] == '!':
		if i % 4 == b:
			b_ans += 1
		elif i % 4 == y:
			y_ans += 1
		elif i % 4 == r:
			r_ans += 1
		elif i % 4 == g:
			g_ans += 1
print(r_ans, b_ans, y_ans, g_ans)


s = input()
n = len(s)
for i in 'RBYG':
	pos = s.find(i) % 4
	print('%d ' % (n // 4 + (n % 4 > pos) - s.count(i)), end='')


s = input()
count = {0: 0, 1: 0, 2: 0, 3: 0}
types = {}
for (i, l) in enumerate(s):
	if l == '!':
		count[i % 4] += 1
	else:
		types[l] = i % 4
print(count[types['R']], count[types['B']], count[types['Y']], count[types['G']])


lights = list(input())
l = len(lights)
(kr, kb, ky, kg) = [0, 0, 0, 0]
for i in range(4):
	count = 0
	for j in range(i, l, 4):
		if lights[j] == '!':
			count += 1
	for j in range(i, l, 4):
		if lights[j] == 'R':
			kr = count
			break
		elif lights[j] == 'B':
			kb = count
			break
		elif lights[j] == 'Y':
			ky = count
			break
		elif lights[j] == 'G':
			kg = count
			break
print(kr, kb, ky, kg)


x = input()
i = 0
result = [0] * 4
place = {}
for c in x:
	if c == '!':
		result[i] += 1
	place[c] = i
	i = (i + 1) % 4
print(result[place['R']], result[place['B']], result[place['Y']], result[place['G']])


def deadbulbs(a, s):
	c = 0
	x = s.index(a)
	if x <= 3:
		pass
	else:
		while x > 3:
			x -= 4
	for i in range(x, len(s), 4):
		if s[i] == '!':
			c += 1
		else:
			continue
	return c
s = input().lower()
l = [deadbulbs('r', s), deadbulbs('b', s), deadbulbs('y', s), deadbulbs('g', s)]
print(*l)


s = input()
n = len(s)
(kr, kb, ky, kg) = (0, 0, 0, 0)
R = s.index('R') % 4
for i in range(R, n, 4):
	if s[i] == '!':
		kr += 1
B = s.index('B') % 4
for i in range(B, n, 4):
	if s[i] == '!':
		kb += 1
Y = s.index('Y') % 4
for i in range(Y, n, 4):
	if s[i] == '!':
		ky += 1
G = s.index('G') % 4
for i in range(G, n, 4):
	if s[i] == '!':
		kg += 1
print(kr, kb, ky, kg)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def main():
	pass

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def lts(l):
	s = ''.join(map(str, l))
	return s

def stl(s):
	l = list(s)
	return l

def sq(a, target, arr=[]):
	s = sum(arr)
	if s == target:
		return arr
	if s >= target:
		return
	for i in range(len(a)):
		n = a[i]
		remaining = a[i + 1:]
		ans = sq(remaining, target, arr + [n])
		if ans:
			return ans

def SieveOfEratosthenes(n):
	cnt = 0
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for p in range(2, n + 1):
		if prime[p]:
			cnt += 1
	return cnt

def nCr(n, r):
	f = math.factorial
	return f(n) // f(r) // f(n - r)
mod = int(1000000000.0) + 7

def ssinp():
	return input()

def iinp():
	return int(input())

def nninp():
	return map(int, input().split())

def llinp():
	return list(map(int, input().split()))

def p(xyz):
	print(xyz)

def p2(a, b):
	print(a, b)
import math
from collections import OrderedDict

def col(ind):
	cnt = 0
	for i in range(ind, -1, -4):
		if s[i] == '!':
			cnt += 1
	for i in range(ind + 4, len(s), 4):
		if s[i] == '!':
			cnt += 1
	return cnt
s = lts(ssinp())
ind1 = ind2 = ind3 = ind4 = 0
for i in range(len(s)):
	if s[i] == 'R':
		ind1 = i
	elif s[i] == 'B':
		ind2 = i
	elif s[i] == 'Y':
		ind3 = i
	elif s[i] == 'G':
		ind4 = i
print(col(ind1), col(ind2), col(ind3), col(ind4))


s = input()
pos = [-1, -1, -1, -1]
count = [0, 0, 0, 0]
for i in range(len(s)):
	if s[i] == '!':
		continue
	if s[i] == 'R':
		pos[0] = i % 4
	if s[i] == 'B':
		pos[1] = i % 4
	if s[i] == 'Y':
		pos[2] = i % 4
	if s[i] == 'G':
		pos[3] = i % 4
for i in range(len(s)):
	if s[i] == '!':
		count[pos.index(i % 4)] += 1
print(*count)


c = 'RBYG'
a = input()
print(*[a[p::4].count('!') for p in [a.index(x) % 4 for x in c]])


s = input()
l = [0, 0, 0, 0]
for i in range(len(s)):
	if s[i] == '!':
		l[i % 4] += 1
c = ['', '', '', '']
for i in range(0, len(s), 4):
	if s[i] != '!':
		c[0] = s[i]
		break
for i in range(1, len(s), 4):
	if s[i] != '!':
		c[1] = s[i]
		break
for i in range(2, len(s), 4):
	if s[i] != '!':
		c[2] = s[i]
		break
for i in range(3, len(s), 4):
	if s[i] != '!':
		c[3] = s[i]
		break
if '' in c:
	a = c.index('')
	if 'R' not in c:
		c[a] = 'R'
	elif 'B' not in c:
		c[a] = 'B'
	elif 'G' not in c:
		c[a] = 'G'
	elif 'Y' not in c:
		c[a] = 'Y'
r = c.index('R')
b = c.index('B')
g = c.index('G')
y = c.index('Y')
print(str(l[r]) + ' ' + str(l[b]) + ' ' + str(l[y]) + ' ' + str(l[g]))


def read_input():
	line = input().strip()
	letter = {'R': -1, 'B': -1, 'Y': -1, 'G': -1}
	number = [0, 0, 0, 0]
	for i in range(4):
		flag = False
		while i < len(line):
			if line[i] != '!':
				if not flag:
					letter[line[i]] = i % 4
					flag = True
			else:
				number[i % 4] += 1
			i += 4
	print(number[letter['R']], number[letter['B']], number[letter['Y']], number[letter['G']])
read_input()


st = input()
rmod = None
bmod = None
ymod = None
gmod = None
for i in range(len(st)):
	if st[i] == 'R':
		rmod = i % 4
	if st[i] == 'B':
		bmod = i % 4
	if st[i] == 'Y':
		ymod = i % 4
	if st[i] == 'G':
		gmod = i % 4
rcount = 0
bcount = 0
ycount = 0
gcount = 0
for i in range(len(st)):
	if st[i] == '!':
		if i % 4 == rmod:
			rcount += 1
		if i % 4 == bmod:
			bcount += 1
		if i % 4 == ymod:
			ycount += 1
		if i % 4 == gmod:
			gcount += 1
print(str(rcount) + ' ' + str(bcount) + ' ' + str(ycount) + ' ' + str(gcount))


def find(s):
	r = -1
	b = -1
	y = -1
	g = -1
	for i in range(len(s)):
		if s[i] == 'R':
			r = i
		elif s[i] == 'B':
			b = i
		elif s[i] == 'Y':
			y = i
		elif s[i] == 'G':
			g = i
	r %= 4
	b %= 4
	y %= 4
	g %= 4
	ans = [0, 0, 0, 0]
	for i in range(len(s)):
		if s[i] == '!':
			ans[i % 4] += 1
	ANS = [0, 0, 0, 0]
	ANS[0] = ans[r]
	ANS[1] = ans[b]
	ANS[2] = ans[y]
	ANS[3] = ans[g]
	return ANS
s = input()
print(*find(s))


s = input()
ans = ''
for j in range(4):
	for i in s[j::4]:
		if i != '!':
			ans += i
			break
arr = {}
arr['R'] = 0
arr['B'] = 0
arr['Y'] = 0
arr['G'] = 0
for j in range(4):
	for i in s[j::4]:
		if i == '!':
			arr[ans[j]] += 1
for i in 'RBYG':
	print(arr[i], end=' ')


a = input()
l = ''
t = 0
R = 0
B = 0
Y = 0
G = 0
a1 = a[0::4]
b2 = a[1::4]
c3 = a[2::4]
d4 = a[3::4]
for i in a1:
	if i == '!':
		t += 1
	if i.isupper():
		l = i
if l == 'R':
	R += t
if l == 'B':
	B += t
if l == 'Y':
	Y += t
if l == 'G':
	G += t
t = 0
for i in b2:
	if i == '!':
		t += 1
	if i.isupper():
		l = i
if l == 'R':
	R += t
if l == 'B':
	B += t
if l == 'Y':
	Y += t
if l == 'G':
	G += t
t = 0
for i in c3:
	if i == '!':
		t += 1
	if i.isupper():
		l = i
if l == 'R':
	R += t
if l == 'B':
	B += t
if l == 'Y':
	Y += t
if l == 'G':
	G += t
t = 0
for i in d4:
	if i == '!':
		t += 1
	if i.isupper():
		l = i
if l == 'R':
	R += t
if l == 'B':
	B += t
if l == 'Y':
	Y += t
if l == 'G':
	G += t
t = 0
print(R, B, Y, G)


s = input()
a = {'R', 'G', 'B', 'Y'}
l = list(s)
dict = {}
if s.__contains__('!') == False:
	print(0, 0, 0, 0)
else:
	for (e, f) in enumerate(l):
		if e % 4 not in dict and f != '!':
			dict[e % 4] = f
	n = {}
	for i in range(len(s)):
		if s[i] == '!':
			if dict[i % 4] not in n:
				n[dict[i % 4]] = 1
			else:
				n[dict[i % 4]] += 1
	b = set()
	for e in n.keys():
		b.add(e)
	s = a.difference(b)
	for e in s:
		n[e] = 0
	print(n['R'], n['B'], n['Y'], n['G'])


from sys import stdin as fin
s = fin.readline().rstrip()
n = len(s)
cnt = {'R': 0, 'B': 0, 'Y': 0, 'G': 0, '!': 0}
pos = {'R': 0, 'B': 0, 'Y': 0, 'G': 0}
rs = None
for i in range(n):
	cnt[s[i]] += 1
	if s[i] != '!':
		pos[s[i]] = i % 4
am = n % 4
for sym in 'RBYG':
	need = None
	if not am or pos[sym] > am - 1:
		need = n // 4
	else:
		need = n // 4 + 1
	print(need - cnt[sym], end=' ')


s = input()
ce = s.count('!')
sr = s.count('R')
sb = s.count('B')
sg = s.count('G')
sy = s.count('Y')
pr = s.find('R')
pb = s.find('B')
pg = s.find('G')
py = s.find('Y')
if ce == 0:
	print(0, 0, 0, 0)
else:
	l = len(s)
	cr = cb = cg = cy = 0
	i = pr
	while i + 4 < l:
		if s[i + 4] == '!':
			cr += 1
		i += 4
	i = pr
	while i - 4 >= 0:
		if s[i - 4] == '!':
			cr += 1
		i -= 4
	i = pg
	while i + 4 < l:
		if s[i + 4] == '!':
			cg += 1
		i += 4
	i = pg
	while i - 4 >= 0:
		if s[i - 4] == '!':
			cg += 1
		i -= 4
	i = pb
	while i + 4 < l:
		if s[i + 4] == '!':
			cb += 1
		i += 4
	i = pb
	while i - 4 >= 0:
		if s[i - 4] == '!':
			cb += 1
		i -= 4
	i = py
	while i + 4 < l:
		if s[i + 4] == '!':
			cy += 1
		i += 4
	i = py
	while i - 4 >= 0:
		if s[i - 4] == '!':
			cy += 1
		i -= 4
	print(cr, cb, cy, cg)


s = list(input().strip())
dead = {'R': 0, 'B': 0, 'Y': 0, 'G': 0}
for i in range(len(s)):
	if s[i] == '!':
		for j in range(i % 4, len(s), 4):
			if s[j] != '!':
				s[i] = s[j]
				dead[s[j]] += 1
				break
print(*dead.values())


x = input()
dict = {'R': 0, 'B': 0, 'Y': 0, 'G': 0}
lists = ['R', 'G', 'B', 'Y']
first = ['!'] * 4
for i in range(4):
	j = i
	if x[j] != '!':
		first[i] = x[j]
	else:
		j += 4
		while j < len(x):
			if x[j] != '!':
				first[i] = x[j]
				dict[x[j]] += 1
				break
			j += 4
if '!' in first:
	x = [x for x in lists if x not in first]
	s = ''.join(x)
	first[first.index('!')] = s
	dict[s] += 1
for i in range(4):
	j = i + 4
	while j < len(x):
		if x[j] == '!':
			dict[first[i]] += 1
		j += 4
print(dict['R'], dict['B'], dict['Y'], dict['G'])


mas = input()
mas1 = [0, 0, 0, 0]
mas1[0] = 0
mas1[1] = 0
mas1[2] = 0
mas1[3] = 0
kr = 0
kb = 0
ky = 0
kg = 0
for x in range(len(mas)):
	if x % 4 == 0 and mas[x] != '!':
		one = mas[x]
	if (x - 1) % 4 == 0 and mas[x] != '!':
		two = mas[x]
	if (x - 2) % 4 == 0 and mas[x] != '!':
		three = mas[x]
	if (x - 3) % 4 == 0 and mas[x] != '!':
		four = mas[x]
for x in range(len(mas)):
	if x % 4 == 0 and mas[x] == '!':
		mas1[0] = mas1[0] + 1
	if (x - 1) % 4 == 0 and mas[x] == '!':
		mas1[1] = mas1[1] + 1
	if (x - 2) % 4 == 0 and mas[x] == '!':
		mas1[2] = mas1[2] + 1
	if (x - 3) % 4 == 0 and mas[x] == '!':
		mas1[3] = mas1[3] + 1
mas = [one, two, three, four]
mas[0] = one
mas[1] = two
mas[2] = three
mas[3] = four
for x in range(4):
	if mas[x] == 'R':
		kr = int(mas1[x])
	elif mas[x] == 'B':
		kb = int(mas1[x])
	elif mas[x] == 'Y':
		ky = int(mas1[x])
	else:
		kg = int(mas1[x])
print(kr, kb, ky, kg)


string = str(input())
zero = string[0::4]
one = string[1::4]
two = string[2::4]
three = string[3::4]
dictionary = dict()
def_value = 0
for start in range(0, 4):
	counter = 0
	symbol = False
	for char in string[start::4]:
		if char == '!':
			counter += 1
		else:
			symbol = char
	if symbol != False:
		dictionary[symbol] = counter
	else:
		def_value = counter
lis = list()
lis.append(str(dictionary.get('R', def_value)))
lis.append(str(dictionary.get('B', def_value)))
lis.append(str(dictionary.get('Y', def_value)))
lis.append(str(dictionary.get('G', def_value)))
print(' '.join(lis))


s = input()
print(' '.join((str(s[s.find(ch) % 4::4].count('!')) for ch in 'RBYG')))


s = input().strip()
result = []
for c in 'RBYG':
	i = s.find(c) % 4
	ss = s[i::4]
	result.append(ss.count('!'))
print(' '.join([str(i) for i in result]))


s = input()
ls = len(s)
sl = [i for i in s]
r = sl.index('R')
b = sl.index('B')
y = sl.index('Y')
g = sl.index('G')
(tr, tb, ty, tg) = (r, b, y, g)
(lr, lb, ly, lg) = ([r], [b], [y], [g])
(f1, f2) = (0, 0)
while 1:
	r -= 4
	tr += 4
	if r >= 0:
		lr.append(r)
	else:
		f1 = 1
	if tr < ls:
		lr.append(tr)
	else:
		f2 = 1
	if f1 and f2:
		break
(f1, f2) = (0, 0)
while 1:
	b -= 4
	tb += 4
	if b >= 0:
		lb.append(b)
	else:
		f1 = 1
	if tb < ls:
		lb.append(tb)
	else:
		f2 = 1
	if f1 and f2:
		break
(f1, f2) = (0, 0)
while 1:
	y -= 4
	ty += 4
	if y >= 0:
		ly.append(y)
	else:
		f1 = 1
	if ty < ls:
		ly.append(ty)
	else:
		f2 = 1
	if f1 and f2:
		break
(f1, f2) = (0, 0)
while 1:
	g -= 4
	tg += 4
	if g >= 0:
		lg.append(g)
	else:
		f1 = 1
	if tg < ls:
		lg.append(tg)
	else:
		f2 = 1
	if f1 and f2:
		break
(kr, kb, ky, kg) = (0, 0, 0, 0)
for i in lr:
	if s[i] == '!':
		kr += 1
for i in lb:
	if s[i] == '!':
		kb += 1
for i in ly:
	if s[i] == '!':
		ky += 1
for i in lg:
	if s[i] == '!':
		kg += 1
print(kr, kb, ky, kg)


import math
str = input()
j = 0
b1 = 0
y1 = 0
r1 = 0
g1 = 0
for i in str:
	if i == 'B':
		b = j % 4
	elif i == 'Y':
		y = j % 4
	elif i == 'R':
		r = j % 4
	elif i == 'G':
		g = j % 4
	j = j + 1
j = 0
for i in str:
	if i == '!' and j % 4 == b:
		b1 = b1 + 1
	elif i == '!' and j % 4 == y:
		y1 = y1 + 1
	elif i == '!' and j % 4 == r:
		r1 = r1 + 1
	elif i == '!' and j % 4 == g:
		g1 = g1 + 1
	j = j + 1
print('%s %s %s %s' % (r1, b1, y1, g1))


import sys, math, io, os, time, itertools, collections
mod = 10 ** 9 + 7
sys.setrecursionlimit(10000)
i = sys.stdin.readline
p = sys.stdout.write
global start, end

def isin(l, x):
	left = 0
	right = len(l) - 1
	if x < l[0]:
		return -1
	while left <= right:
		mid = left + (right - left) // 2
		if l[mid] == x:
			return mid
		elif l[mid] < x:
			ans = mid
			left = mid + 1
		else:
			right = mid - 1
	return ans

def ispal(l):
	n = len(l)
	for i in range(n // 2 + 1):
		if l[i] != l[n - i - 1]:
			return False
	return True

def ccarray(l):
	d = {l[k]: k for k in range(len(l))}
	m = sorted(d)
	return [d[m[k]] for k in range(len(l))]

def is_prime(n):
	if n <= 3:
		return n > 1
	if n % 2 == 0 or n % 3 == 0:
		return False
	k = 5
	while k ** 2 <= n:
		if n % k == 0 or n % (k + 2) == 0:
			return False
		k += 6
	return True

def sieve(n):
	prime = [True for k in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for k in range(p * p, n + 1, p):
				prime[k] = False
		p += 1

def main():
	s = i().strip()
	rind = s.index('R') % 4
	bind = s.index('B') % 4
	yind = s.index('Y') % 4
	gind = s.index('G') % 4
	count = {rind: 0, bind: 0, yind: 0, gind: 0}
	for k in range(len(s)):
		if s[k] == '!':
			count[k % 4] += 1
	for key in count.keys():
		p(str(count[key]) + ' ')
	p('\n')
t = 1
start = time.perf_counter()
for _ in range(t):
	main()
end = time.perf_counter()


import copy
lights = input().strip()
init_val = 0
pos = 0
while True:
	pos = lights.find('!!!!', pos)
	if pos > -1:
		init_val += 1
		pos += 4
	else:
		break
lights = lights.replace('!!!!', '')
l = []
for c in lights:
	if c == '!':
		l += [{'R': 1, 'B': 1, 'Y': 1, 'G': 1}]
	else:
		l += [{c: 0}]
counts = {'R': init_val, 'B': init_val, 'Y': init_val, 'G': init_val}

def run_opt(l):
	invalid = 1
	while invalid:
		invalid = 0
		didsmth = False
		for i in range(len(l)):
			if len(l[i]) > 1:
				for j in range(-3, 4):
					if i + j >= 0 and i + j < len(l) and (i + j != i):
						other = l[i + j]
						if len(other) == 1:
							for key in other.keys():
								if key in l[i]:
									didsmth = True
									del l[i][key]
				if len(l[i]) > 1:
					invalid = 1
		if not didsmth:
			break
	for el in l:
		if len(el) == 0:
			invalid = -1
			break
	return invalid
import time

def more_opt(l):
	indices_order = [i[0] for i in sorted(enumerate(l), key=lambda x: len(x[1]))]
	for i in indices_order:
		if len(l[i]) > 1:
			for k in l[i]:
				l_prime = copy.deepcopy(l)
				l_prime[i] = {k: 1}
				status = run_opt(l_prime)
				if status == 1:
					return more_opt(l_prime)
				elif status == 0:
					return l_prime
	raise RuntimeError('nope')
invalid = run_opt(l)
if invalid:
	l = more_opt(l)
for el in l:
	for k in el:
		if el[k] == 1:
			counts[k] += 1
print('{} {} {} {}'.format(counts['R'], counts['B'], counts['Y'], counts['G']))


a = input()
b = a.index('B') % 4
r = a.index('R') % 4
g = a.index('G') % 4
y = a.index('Y') % 4
tb = 0
tr = 0
tg = 0
ty = 0
for i in range(len(a)):
	if a[i] == '!':
		z = i % 4
		if z == b:
			tb += 1
		if z == r:
			tr += 1
		if z == g:
			tg += 1
		if z == y:
			ty += 1
print(tr, tb, ty, tg)


from sys import stdin, stdout

def I():
	return int(stdin.readline())

def In():
	return map(int, stdin.readline().split())

def S():
	return stdin.readline().rstrip()

def Sn():
	return stdin.readline().split(' ')

def Out(whatever):
	return stdout.write(whatever)

def func(s):
	n = len(s)
	x = [0] * 4
	patt = [''] * 4
	for i in range(4):
		for j in range(i, n, 4):
			if s[j] == '!':
				x[i] += 1
			else:
				patt[i] = s[j]
	ans = {patt[i]: x[i] for i in range(4)}
	return '{} {} {} {}'.format(ans['R'], ans['B'], ans['Y'], ans['G'])
s = S()
Out(func(s))


def myf(s):
	result = {'R': 0, 'G': 0, 'Y': 0, 'B': 0}
	position = {'R': -1, 'G': -1, 'Y': -1, 'B': -1}
	slen = len(s)
	for i in range(slen):
		if s[i] == 'R':
			position[s[i]] = i % 4
		elif s[i] == 'B':
			position[s[i]] = i % 4
		elif s[i] == 'Y':
			position[s[i]] = i % 4
		elif s[i] == 'G':
			position[s[i]] = i % 4
		if sum(position.values()) >= 10:
			break
	for i in range(slen):
		if s[i] == '!':
			pos = i % 4
			for (key, value) in position.items():
				if value == pos:
					result[key] += 1
	return result
s = input()
res = myf(s)
print(res['R'], res['B'], res['Y'], res['G'])


def check(s1, s2):
	for i in range(3):
		if s1[i] != s2[i] and s2[i] != '!':
			return False
	if len(set(s1)) != len(s2[:3]):
		return False
	return True
s = input()
ss = 'RGYB'
for i in ss:
	for j in ss:
		for k in ss:
			if check(i + j + k, s):
				curr_elem = list(i + j + k)
				for l in range(3, len(s)):
					block = set([curr_elem[l - 1], curr_elem[l - 2], curr_elem[l - 3]])
					if s[l] in block:
						break
					elif s[l] == '!':
						ok = True
						for m in ss:
							if m not in block:
								curr_elem += [m]
								ok = False
								break
						if ok:
							break
					else:
						curr_elem += s[l]
				if len(curr_elem) == len(s):
					d = dict()
					for q in ss:
						d[q] = 0
					for q in range(len(curr_elem)):
						if s[q] == '!':
							d[curr_elem[q]] = d.get(curr_elem[q], 0) + 1
					print(d['R'], d['B'], d['Y'], d['G'])
					exit()


s = input()
r = b = y = g = 0
for i in range(len(s)):
	if s[i] == 'R':
		r = i % 4
	elif s[i] == 'B':
		b = i % 4
	elif s[i] == 'Y':
		y = i % 4
	elif s[i] == 'G':
		g = i % 4
	else:
		continue
R = B = Y = G = 0
for i in range(len(s)):
	if s[i] == '!':
		if i % 4 == r:
			R += 1
		elif i % 4 == b:
			B += 1
		elif i % 4 == y:
			Y += 1
		else:
			G += 1
print(R, B, Y, G, sep=' ')


def read(type=int):
	return type(input())

def read_arr(type=int):
	return [type(token) for token in input().split()]
mod = 10 ** 9 + 7

def mod_sum(A):
	s = 0
	for a in A:
		s = (s + a) % mod
	return s

def show(DP):
	for row in DP:
		print(row)
	print()

def solution():
	pass

def run():
	s = list(input())
	n = len(s)
	R = -1
	G = -1
	B = -1
	Y = -1
	cB = cR = cG = cY = 0
	for i in range(len(s)):
		if s[i] == 'B' and B == -1:
			B = i
		elif s[i] == 'R' and R == -1:
			R = i
		elif s[i] == 'G' and G == -1:
			G = i
		elif s[i] == 'Y' and Y == -1:
			Y = i
	if B != -1:
		for i in range(B, n, 4):
			if s[i] == '!':
				s[i] = 'B'
				cB += 1
		for i in range(B, -1, -4):
			if s[i] == '!':
				s[i] = 'B'
				cB += 1
	if G != -1:
		for i in range(G, n, 4):
			if s[i] == '!':
				s[i] = 'G'
				cG += 1
		for i in range(G, -1, -4):
			if s[i] == '!':
				s[i] = 'G'
				cG += 1
	if R != -1:
		for i in range(R, n, 4):
			if s[i] == '!':
				s[i] = 'R'
				cR += 1
		for i in range(R, -1, -4):
			if s[i] == '!':
				s[i] = 'R'
				cR += 1
	if Y != -1:
		for i in range(Y, n, 4):
			if s[i] == '!':
				s[i] = 'Y'
				cY += 1
		for i in range(Y, -1, -4):
			if s[i] == '!':
				s[i] = 'Y'
				cY += 1
	extra = 0
	for i in range(n):
		if s[i] == '!':
			extra += 1
	if B == -1:
		cB += extra
	elif G == -1:
		cG += extra
	elif R == -1:
		cR += extra
	elif Y == -1:
		cY += extra
	print(cR, cB, cY, cG)
run()


s = list(input())
n = len(s)
tmp = [0, 0, 0, 0]
d = {'R': 0, 'B': 0, 'Y': 0, 'G': 0}
for i in range(n):
	if s[i] == '!':
		tmp[i % 4] += 1
	else:
		d[s[i]] = i % 4
ans = [0, 0, 0, 0]
t = ['R', 'B', 'Y', 'G']
for i in range(4):
	ans[i] = tmp[d[t[i]]]
print(*ans)


s = input()
d = {}
d['R'] = 0
d['G'] = 0
d['Y'] = 0
d['B'] = 0
ans = [''] * 4
j = 0
for i in range(len(s)):
	if s[i] == '!':
		j = (j + 1) % 4
	else:
		ans[j] = s[i]
		j = (j + 1) % 4
	if '' not in ans:
		break
for i in range(len(s)):
	j = i % 4
	if s[i] != ans[j]:
		d[ans[j]] += 1
print(d['R'], d['B'], d['Y'], d['G'])


tab = list(input())
if '!' not in tab:
	print(0, 0, 0, 0)
else:
	dic = {'R': 0, 'B': 0, 'Y': 0, 'G': 0}
	for i in range(len(tab)):
		if tab[i] == '!':
			for j in range(len(tab)):
				if i % 4 == j % 4 and tab[j] != '!':
					dic[tab[j]] += 1
					break
	print(dic['R'], dic['B'], dic['Y'], dic['G'])


s = input()
n = len(s)
mas = [0] * 4
for i in range(4):
	mas[i] = [0, 0]
for i in range(n):
	if s[i] == 'R':
		mas[0][0] += 1
		mas[0][1] = (i + 1) % 4
	if s[i] == 'B':
		mas[1][0] += 1
		mas[1][1] = (i + 1) % 4
	if s[i] == 'Y':
		mas[2][0] += 1
		mas[2][1] = (i + 1) % 4
	if s[i] == 'G':
		mas[3][0] += 1
		mas[3][1] = (i + 1) % 4
c = n // 4
k = n % 4
for i in range(4):
	if mas[i][1] > 0 and mas[i][1] <= k:
		mas[i] = c + 1 - mas[i][0]
	else:
		mas[i] = c - mas[i][0]
print(*mas)


s = input()
c = {}
ans = {'R': 0, 'G': 0, 'Y': 0, 'B': 0}
for i in range(len(s)):
	if s[i] != '!':
		c[i % 4] = s[i]
for i in range(len(s)):
	if s[i] == '!':
		ans[c[i % 4]] += 1
for i in 'RBYG':
	print(ans[i], end=' ')


s = input()
a = ['*'] * 4
for (i, c) in enumerate(s):
	if c != '!':
		a[i % 4] = c
answ = dict(R=0, G=0, B=0, Y=0)
for i in range(len(s)):
	if s[i] == '!':
		answ[a[i % 4]] += 1
print(answ['R'], answ['B'], answ['Y'], answ['G'])


s = input()
d = {i: '' for i in range(4)}
ans = [0] * 4
for (a, i) in enumerate(s):
	if i != '!':
		d[a % 4] = i
for (a, i) in enumerate(s):
	if i == '!':
		if d[a % 4] == 'R':
			ans[0] += 1
		elif d[a % 4] == 'B':
			ans[1] += 1
		elif d[a % 4] == 'Y':
			ans[2] += 1
		else:
			ans[3] += 1
print(*ans)


order = [''] * 4
s = input()
for i in range(len(s)):
	if s[i] != '!':
		order[i % 4] = s[i]
cnt = {key: 0 for key in 'RBYG'}
for i in range(len(s)):
	if s[i] == '!':
		cnt[order[i % 4]] += 1
print('%d %d %d %d' % (cnt['R'], cnt['B'], cnt['Y'], cnt['G']))


def Lights(x):
	count = 0
	a = '0'
	for i in range(x, len(somelist), 4):
		if somelist[i] != '!':
			a = somelist[i]
	if a == 'R':
		num = 1
	elif a == 'B':
		num = 2
	elif a == 'Y':
		num = 3
	elif a == 'G':
		num = 4
	for j in range(x, len(somelist), 4):
		if somelist[j] == a:
			pass
		elif somelist[j] == '!':
			count += 1
		else:
			raise ValueError
	return (count, num)
try:
	somelist = input()
	if len(somelist) < 4 or len(somelist) > 100:
		raise ValueError
	for i in range(len(somelist)):
		if somelist[i] == 'R' or somelist[i] == 'B' or somelist[i] == 'Y' or (somelist[i] == 'G') or (somelist[i] == '!'):
			pass
		else:
			raise ValueError
	(count1, num1) = Lights(0)
	(count2, num2) = Lights(1)
	(count3, num3) = Lights(2)
	(count4, num4) = Lights(3)
	d = {num1: count1, num2: count2, num3: count3, num4: count4}
except ValueError:
	print('Wrong string')
else:
	d2 = ' '.join(map(str, list(d.values())))
	print(d2)


s = input()
r = b = y = g = 0
f = [None for i in range(4)]
for i in range(len(s)):
	if s[i] != '!':
		f[i % 4] = s[i]
	if not f.count(None):
		break
for i in range(len(s)):
	if s[i] == '!':
		c = f[i % 4]
		if c == 'R':
			r += 1
		elif c == 'Y':
			y += 1
		elif c == 'B':
			b += 1
		else:
			g += 1
print(r, b, y, g, sep=' ')


s = input()
t = ['R', 'B', 'Y', 'G']
ans = [0] * 4
mp = ['a'] * 4
for idx in range(4):
	pos = idx
	while pos < len(s):
		if s[pos] == '!':
			ans[idx] += 1
		else:
			mp[idx] = s[pos]
		pos += 4
for i in range(4):
	for j in range(4):
		if t[i] == mp[j]:
			print(str(ans[j]) + ' ', end='')


input_string = input()
my_array = []
r = 0
b = 0
y = 0
g = 0
flag = dict(r=False, b=False, y=False, g=False)
counter = dict(r=0, b=0, y=0, g=0)
for i in range(len(input_string)):
	my_array.append(input_string[i])
k = 0
for i in range(len(input_string)):
	if (my_array[i] == 'R') & (flag['r'] == False):
		while i >= 4:
			i -= 4
		r = i
		k += 1
		flag['r'] = True
	if (my_array[i] == 'B') & (flag['b'] == False):
		while i >= 4:
			i -= 4
		b = i
		k += 1
		flag['b'] = True
	if (my_array[i] == 'Y') & (flag['y'] == False):
		while i >= 4:
			i -= 4
		y = i
		k += 1
		flag['y'] = True
	if (my_array[i] == 'G') & (flag['g'] == False):
		while i >= 4:
			i -= 4
		g = i
		k += 1
		flag['g'] = True
	if k == 4:
		break
for i in range(len(my_array)):
	if my_array[i] == '!':
		if i % 4 == r:
			counter['r'] += 1
		if i % 4 == b:
			counter['b'] += 1
		if i % 4 == y:
			counter['y'] += 1
		if i % 4 == g:
			counter['g'] += 1
print(counter['r'], ' ', counter['b'], ' ', counter['y'], ' ', counter['g'])


s = list(input())
result = {'R': 0, 'B': 0, 'Y': 0, 'G': 0}
for mod in [0, 1, 2, 3]:
	w = filter(lambda x: s[x] == '!', range(mod, len(s), 4))
	letter = next(filter(lambda x: s[x] != '!', range(mod, len(s), 4)))
	result[s[letter]] = len(list(w))
print('{0} {1} {2} {3}'.format(result['R'], result['B'], result['Y'], result['G']))


import math
s = input()
i = 1
a = [[], [], [], []]
for _ in s:
	if i == 1:
		a[i - 1].append(_)
		i = 2
	elif i == 2:
		a[i - 1].append(_)
		i = 3
	elif i == 3:
		a[i - 1].append(_)
		i = 4
	else:
		a[i - 1].append(_)
		i = 1
data = {'R': 0, 'B': 0, 'Y': 0, 'G': 0}
for _ in a:
	cnt = 0
	ans = '!'
	for x in _:
		if x == '!':
			cnt = cnt + 1
		else:
			ans = x
	data[ans] = str(cnt)
print(data['R'] + ' ' + data['B'] + ' ' + data['Y'] + ' ' + data['G'])


import os
import sys
from io import BytesIO, IOBase

def main():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()
n = input()
first = {}
for i in range(len(n)):
	if n[i] != '!':
		first[i % 4] = n[i]
value = {'R': 0, 'B': 0, 'Y': 0, 'G': 0}
for j in range(len(n)):
	if n[j] == '!':
		value[first[j % 4]] += 1
print(value['R'], value['B'], value['Y'], value['G'])


st = input()
l = len(st)
dead = [0] * 4
ctr = [0] * 4
for i in range(l):
	if st[i] == 'R':
		ctr[0] = i % 4
	elif st[i] == 'B':
		ctr[1] = i % 4
	elif st[i] == 'Y':
		ctr[2] = i % 4
	elif st[i] == 'G':
		ctr[3] = i % 4
for i in range(l):
	j = 0
	if st[i] == '!':
		for j in range(4):
			if i % 4 == ctr[j]:
				break
		dead[j] = dead[j] + 1
for i in range(4):
	print(dead[i], end=' ')


import math, sys

def main():
	l = input()
	rr = 0
	br = 0
	gr = 0
	yr = 0
	for i in range(len(l)):
		if l[i] == 'R':
			rr = i % 4
		if l[i] == 'B':
			br = i % 4
		if l[i] == 'Y':
			yr = i % 4
		if l[i] == 'G':
			gr = i % 4
	rk = 0
	bk = 0
	gk = 0
	yk = 0
	for i in range(len(l)):
		if l[i] == '!':
			if i % 4 == rr:
				rk += 1
			if i % 4 == br:
				bk += 1
			if i % 4 == yr:
				yk += 1
			if i % 4 == gr:
				gk += 1
	print(rk, bk, yk, gk)
main()


s = input()
idxR = s.index('R') % 4
sumR = sum((c == '!' for c in s[idxR::4]))
idxB = s.index('B') % 4
sumB = sum((c == '!' for c in s[idxB::4]))
idxY = s.index('Y') % 4
sumY = sum((c == '!' for c in s[idxY::4]))
idxG = s.index('G') % 4
sumG = sum((c == '!' for c in s[idxG::4]))
print(sumR, sumB, sumY, sumG)


s = input()
n = len(s)
colors = {'R': 0, 'B': 0, 'Y': 0, 'G': 0}
for i in range(4):
	curr = ''
	dmg = 0
	for j in range(i, n, 4):
		if s[j] == '!':
			dmg += 1
		else:
			curr = s[j]
	colors[curr] = dmg
for color in colors:
	print(colors[color], end=' ')


import sys
string = input()
r = b = y = g = 0
l1 = string.index('R') % 4
l2 = string.index('B') % 4
l3 = string.index('Y') % 4
l4 = string.index('G') % 4
for i in range(len(string)):
	if string[i] == '!':
		if i % 4 == l1:
			r += 1
		elif i % 4 == l2:
			b += 1
		elif i % 4 == l3:
			y += 1
		elif i % 4 == l4:
			g += 1
print(r, b, y, g)


lamp = input()
count = 0
urai = 0
(w1, w2, w3, w4) = ('', '', '', '')
(d1, d2, d3, d4) = (0, 0, 0, 0)
while urai < len(lamp):
	count += 1
	if lamp[urai] != '!':
		if count == 1:
			w1 = lamp[urai]
		elif count == 2:
			w2 = lamp[urai]
		elif count == 3:
			w3 = lamp[urai]
		elif count == 4:
			w4 = lamp[urai]
	elif count == 1:
		d1 += 1
	elif count == 2:
		d2 += 1
	elif count == 3:
		d3 += 1
	elif count == 4:
		d4 += 1
	if count == 4:
		count = 0
	urai += 1
if w1 == 'R':
	if w2 == 'B':
		if w3 == 'Y':
			print(d1, d2, d3, d4)
		elif w3 == 'G':
			print(d1, d2, d4, d3)
	elif w2 == 'Y':
		if w3 == 'G':
			print(d1, d4, d2, d3)
		elif w3 == 'B':
			print(d1, d3, d2, d4)
	elif w2 == 'G':
		if w3 == 'Y':
			print(d1, d4, d3, d2)
		elif w3 == 'B':
			print(d1, d3, d4, d2)
elif w2 == 'R':
	if w1 == 'B':
		if w3 == 'G':
			print(d2, d1, d4, d3)
		elif w3 == 'Y':
			print(d2, d1, d3, d4)
	elif w1 == 'Y':
		if w3 == 'G':
			print(d2, d4, d1, d3)
		elif w3 == 'B':
			print(d2, d3, d1, d4)
	elif w1 == 'G':
		if w3 == 'Y':
			print(d2, d4, d3, d1)
		elif w3 == 'B':
			print(d2, d3, d4, d1)
elif w3 == 'R':
	if w1 == 'Y':
		if w2 == 'G':
			print(d3, d4, d2, d1)
		elif w2 == 'B':
			print(d3, d2, d1, d4)
	elif w1 == 'G':
		if w2 == 'Y':
			print(d3, d4, d2, d1)
		elif w2 == 'B':
			print(d3, d2, d4, d1)
	elif w1 == 'B':
		if w2 == 'Y':
			print(d3, d1, d2, d4)
		elif w2 == 'G':
			print(d3, d1, d4, d2)
elif w4 == 'R':
	if w1 == 'Y':
		if w2 == 'G':
			print(d4, d3, d1, d2)
		elif w2 == 'B':
			print(d4, d2, d1, d3)
	elif w1 == 'G':
		if w2 == 'Y':
			print(d4, d3, d2, d1)
		elif w2 == 'B':
			print(d4, d2, d3, d1)
	elif w1 == 'B':
		if w2 == 'Y':
			print(d4, d1, d2, d3)
		elif w2 == 'G':
			print(d4, d1, d3, d2)


s = input()
l = [s[i::4] for i in range(4)]
ans = [0 for i in range(4)]
t = 'RBYG'
for i in range(4):
	for j in range(4):
		if t[j] in l[i]:
			ans[j] = l[i].count('!')
for i in range(4):
	print(ans[i], end=' ')
print('')


s = list(input())
l = len(s) - len(s) % 4
sp = [' '] * 4
d = {'R': 0, 'G': 0, 'Y': 0, 'B': 0}
for i in range(0, len(s)):
	if s[i] != '!':
		sp[i % 4] = s[i]
if sp.count('R') == 0:
	sp[sp.find('!')] = 'R'
if sp.count('B') == 0:
	sp[sp.find('!')] = 'B'
if sp.count('Y') == 0:
	sp[sp.find('!')] = 'Y'
if sp.count('G') == 0:
	sp[sp.find('!')] = 'G'
for i in range(0, len(s)):
	if s[i] == '!':
		d[sp[i % 4]] += 1
print(d['R'], d['B'], d['Y'], d['G'])


from collections import Counter
girland = input()
int_to_rbyg = {}
for (i, lamp) in enumerate(girland):
	if lamp != '!' and lamp not in int_to_rbyg:
		int_to_rbyg[i % 4] = lamp
RBYG = dict([(x, 0) for x in 'RBYG'])
for (i, lamp) in enumerate(girland):
	if lamp == '!':
		color = int_to_rbyg[i % 4]
		RBYG[color] += 1
print(*[RBYG[x] for x in 'RBYG'])


lights_string = input()
missing = {'R': 0, 'B': 0, 'Y': 0, 'G': 0}
lights = [c for c in lights_string]
for index in range(len(lights)):
	if lights[index] != '!' and index + 4 < len(lights) and (lights[index + 4] == '!'):
		missing[lights[index]] += 1
		lights[index + 4] = lights[index]
for index in range(len(lights) - 1, -1, -1):
	if lights[index] != '!' and index - 4 > -1 and (lights[index - 4] == '!'):
		missing[lights[index]] += 1
		lights[index - 4] = lights[index]
print('{} {} {} {}'.format(missing['R'], missing['B'], missing['Y'], missing['G']))


def main():
	string = input()
	dic = {}
	for i in range(0, 4):
		count = 0
		colour = ''
		for j in range(i, len(string), 4):
			if string[j] == '!':
				count += 1
			elif colour == '':
				colour = string[j]
		dic[colour] = count
	print(dic['R'], dic['B'], dic['Y'], dic['G'])
main()


s = input()
for i in range(0, len(s)):
	if s[i] == 'R':
		r = i
	if s[i] == 'B':
		b = i
	if s[i] == 'Y':
		y = i
	if s[i] == 'G':
		g = i
r = r % 4
b = b % 4
y = y % 4
g = g % 4
ar = 0
ab = 0
ay = 0
ag = 0
for i in range(0, len(s)):
	if s[i] == '!':
		if i % 4 == r:
			ar = ar + 1
		if i % 4 == b:
			ab = ab + 1
		if i % 4 == y:
			ay = ay + 1
		if i % 4 == g:
			ag = ag + 1
print(ar, ab, ay, ag)


def f(c):
	if c == 'r':
		return 1
	elif c == 'b':
		return 2
	elif c == 'y':
		return 3
	elif c == 'g':
		return 4
	return 0
a = [0, 0, 0, 0, 0]
ans = [0, 0, 0, 0, 0]
s = list(input().lower())
n = len(s)
for i in range(n):
	if s[i] != '!':
		a[i % 4] = f(s[i])
for i in range(n):
	if s[i] == '!':
		ans[a[i % 4]] += 1
print(ans[1], ans[2], ans[3], ans[4])


s = list(input())
kr = 0
kb = 0
ky = 0
kg = 0
r = s.index('R')
b = s.index('B')
y = s.index('Y')
g = s.index('G')
for i in range(len(s)):
	if s[i] == '!':
		if abs(r - i) % 4 == 0:
			kr += 1
		elif abs(b - i) % 4 == 0:
			kb += 1
		elif abs(y - i) % 4 == 0:
			ky += 1
		elif abs(g - i) % 4 == 0:
			kg += 1
print(kr, end=' ')
print(kb, end=' ')
print(ky, end=' ')
print(kg)


a = input()
v = [''] * 4
s = [0] * 4
for i in range(len(a)):
	if i % 4 == 0:
		if a[i] != '!':
			v[i % 4] = a[i]
	if i % 4 == 1:
		if a[i] != '!':
			v[i % 4] = a[i]
	if i % 4 == 2:
		if a[i] != '!':
			v[i % 4] = a[i]
	if i % 4 == 3:
		if a[i] != '!':
			v[i % 4] = a[i]
for i in range(len(a)):
	if a[i] == '!':
		if v[i % 4] == 'R':
			s[0] += 1
		if v[i % 4] == 'B':
			s[1] += 1
		if v[i % 4] == 'Y':
			s[2] += 1
		if v[i % 4] == 'G':
			s[3] += 1
for i in range(4):
	print(s[i], end=' ')


grld = input()
(r, b, y, g) = (0, 0, 0, 0)

def kek(x):
	global r, b, y, g
	tmp = 0
	p = ''
	for i in range(x, len(grld), 4):
		if grld[i] == '!':
			tmp += 1
		else:
			p = grld[i]
	if p == 'R':
		r = tmp
	elif p == 'Y':
		y = tmp
	elif p == 'B':
		b = tmp
	elif p == 'G':
		g = tmp
kek(0)
kek(1)
kek(2)
kek(3)
print(r, b, y, g)


import sys
input = lambda : sys.stdin.readline()
import functools

@functools.lru_cache(maxsize=10000)
def Main():
	s = input()
	t = 'RBYG'
	for i in t:
		idx = s.find(i) % 4
		ans = 0
		while idx < len(s):
			ans += s[idx] == '!'
			idx += 4
		print(ans)
Main()


s = input()
n = len(s)
t = 'RBYG'
for i in t:
	ind = s.find(i) % 4
	ans = 0
	while ind < n:
		ans += s[ind] == '!'
		ind += 4
	print(ans, end=' ')


arr = input()
n = len(arr)
(r, b, y, g) = (0, 0, 0, 0)
for i in range(4):
	if i >= n:
		break
	ltrs = sorted(arr[i::4])
	let = ltrs[len(ltrs) - 1]
	a = ltrs.count('!')
	if let == 'R':
		r += a
	elif let == 'B':
		b += a
	elif let == 'Y':
		y += a
	elif let == 'G':
		g += a
print(r, b, y, g)


s = input()
col = ['R', 'B', 'Y', 'G']
p = [0] * 4
sootv = [0] * 4
for i in range(len(s)):
	if s[i] == '!':
		p[i % 4] += 1
	elif s[i] in col:
		t = col.index(s[i])
		sootv[t] = i % 4
print(' '.join([str(p[sootv[i]]) for i in range(4)]))


s = input()
cnt = s.count('!')
red = 0
green = 0
yellow = 0
blue = 0
while cnt != 0:
	for i in range(len(s) - 4):
		if s[i] == '!' and s[i + 4] != '!':
			s = s[:i] + s[i + 4] + s[i + 1:]
			if s[i + 4] == 'R':
				red += 1
			elif s[i + 4] == 'Y':
				yellow += 1
			elif s[i + 4] == 'G':
				green += 1
			else:
				blue += 1
			cnt -= 1
			continue
		elif s[i] != '!' and s[i + 4] == '!':
			if i == len(s) - 4:
				s = s[:i + 4] + s[i]
			else:
				s = s[:i + 4] + s[i] + s[i + 5:]
			if s[i] == 'R':
				red += 1
			elif s[i] == 'Y':
				yellow += 1
			elif s[i] == 'G':
				green += 1
			else:
				blue += 1
			cnt -= 1
			continue
		temp = s[i:i + 4]
		if temp.count('!') == 1:
			ind = temp.find('!')
			if 'R' not in temp:
				red += 1
				cnt -= 1
				s = s[:i + ind] + 'R' + s[i + 1 + ind:]
			elif 'Y' not in temp:
				yellow += 1
				cnt -= 1
				s = s[:i + ind] + 'Y' + s[i + 1 + ind:]
			elif 'G' not in temp:
				green += 1
				cnt -= 1
				s = s[:i + ind] + 'G' + s[i + 1 + ind:]
			else:
				blue += 1
				cnt -= 1
				s = s[:i + ind] + 'B' + s[i + 1 + ind:]
print(red, blue, yellow, green)


from fractions import gcd
from heapq import *
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import fractions
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7

def main():
	s = list(input())
	(r, y, g, b) = (0, 0, 0, 0)
	for k in range(100):
		for i in range(len(s)):
			if s[i] == '!':
				if i + 4 < len(s):
					if s[i + 4] != '!':
						s[i] = s[i + 4]
						if s[i + 4] == 'R':
							r += 1
						if s[i + 4] == 'Y':
							y += 1
						if s[i + 4] == 'G':
							g += 1
						if s[i + 4] == 'B':
							b += 1
						break
				if i - 4 >= 0:
					if s[i - 4] != '!':
						s[i] = s[i - 4]
						if s[i - 4] == 'R':
							r += 1
						if s[i - 4] == 'Y':
							y += 1
						if s[i - 4] == 'G':
							g += 1
						if s[i - 4] == 'B':
							b += 1
	print(r, b, y, g)
main()


s = input()
a = s.find('R') % 4
b = s.find('B') % 4
c = s.find('Y') % 4
d = s.find('G') % 4
res = [0] * 4
for i in range(len(s)):
	if s[i] == '!':
		res[i % 4] += 1
print(res[a], res[b], res[c], res[d])


import itertools
import collections
x = input()
erg = -1
pos = 'R B Y G'.split()
for p in itertools.permutations(pos):
	t = p * 30
	t[:len(x)]
	tmp = collections.defaultdict(int)
	for i in range(len(x)):
		if x[i] == '!':
			tmp[t[i]] += 1
			continue
		if x[i] == t[i]:
			continue
		else:
			tmp = -1
			break
	if tmp == -1:
		continue
	else:
		print('{} {} {} {}'.format(tmp['R'], tmp['B'], tmp['Y'], tmp['G']))
		break


s = input()
l = []
r = []
b = []
y = []
g = []
for i in range(len(s)):
	if s[i] == '!':
		l.append(i)
	if s[i] == 'R':
		r.append(i)
	if s[i] == 'B':
		b.append(i)
	if s[i] == 'Y':
		y.append(i)
	if s[i] == 'G':
		g.append(i)
ri = r[0] % 4
bi = b[0] % 4
yi = y[0] % 4
gi = g[0] % 4
colours = []
red = 0
green = 0
blue = 0
yellow = 0
if len(l) == 0:
	print(*[0, 0, 0, 0])
else:
	for i in range(len(l)):
		if l[i] % 4 == ri:
			red += 1
		if l[i] % 4 == bi:
			blue += 1
		if l[i] % 4 == gi:
			green += 1
		if l[i] % 4 == yi:
			yellow += 1
	colours.append(red)
	colours.append(blue)
	colours.append(yellow)
	colours.append(green)
	print(*colours)


s = input()
m = 'RBYG'
for i in m:
	index = s.find(i) % 4
	cnt = 0
	while index < len(s):
		if s[index] == '!':
			cnt += 1
		index += 4
	print(cnt, end=' ')


s = input()
Q = s.count('!')
a = []
i0 = i1 = i2 = i3 = ''
if Q == 0:
	print(0, 0, 0, 0)
else:
	for i in range(len(s)):
		if i % 4 == 0 and s[i] != '!':
			i0 = s[i]
			next
		if i % 4 == 1 and s[i] != '!':
			i1 = s[i]
			next
		if i % 4 == 2 and s[i] != '!':
			i2 = s[i]
			next
		if i % 4 == 3 and s[i] != '!':
			i3 = s[i]
			next
		if s[i] == '!':
			a.append(i)
	i0count = i1count = i2count = i3count = 0
	for i in range(len(a)):
		if a[i] % 4 == 0:
			i0count += 1
		if a[i] % 4 == 1:
			i1count += 1
		if a[i] % 4 == 2:
			i2count += 1
		if a[i] % 4 == 3:
			i3count += 1
	bb = ['R', 'B', 'Y', 'G']
	b = [i0, i1, i2, i3]
	c = [i0count, i1count, i2count, i3count]
	d = []
	R = B = Y = G = 0
	for i in range(4):
		for j in range(4):
			if bb[i] == b[j]:
				d.append(c[j])
	print(' '.join(map(str, d)))


import sys
import re
import math
import itertools
import collections
import bisect
mod = 1000000007
pi = 3.141592653589793
IS = float('inf')
xy = [(1, 0), (-1, 0), (0, 1), (0, -1)]
bs = [(-1, -1), (-1, 1), (1, 1), (1, -1)]

def niten(a, b):
	return abs(a - b) if a >= 0 and b >= 0 else a + abs(b) if a >= 0 else abs(a) + b if b >= 0 else abs(abs(a) - abs(b))

def fib(n):
	return [(seq.append(seq[i - 2] + seq[i - 1]), seq[i - 2])[1] for seq in [[0, 1]] for i in range(2, n)]

def gcd(a, b):
	return a if b == 0 else gcd(b, a % b)

def lcm(a, b):
	return a * b / gcd(a, b)

def eucl(x1, y1, x2, y2):
	return ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5

def choco(xa, ya, xb, yb, xc, yc, xd, yd):
	return 1 if abs((yb - ya) * (yd - yc) + (xb - xa) * (xd - xc)) < 1e-10 else 0

def pscl(num, l=[1]):
	for i in range(num):
		l = map(lambda x, y: x + y, [0] + l, l + [0])
	return l
ans = [0] * 4
ls = [0] * 4
chk = {'R': -1, 'G': -1, 'B': -1, 'Y': -1}
h = {i: '' for i in range(4)}
n = input()
for (a, i) in enumerate(n):
	if i == 'R':
		chk[i] = a % 4
		ls[a % 4] = 1
		h[a % 4] = i
	elif i == 'G':
		chk[i] = a % 4
		ls[a % 4] = 1
		h[a % 4] = i
	elif i == 'B':
		chk[i] = a % 4
		ls[a % 4] = 1
		h[a % 4] = i
	elif i == 'Y':
		chk[i] = a % 4
		ls[a % 4] = 1
		h[a % 4] = i
for i in chk:
	if chk[i] == -1:
		for j in range(4):
			if ls[j] == 0:
				chk[i] = j
				h[j] = i
				break
for (a, i) in enumerate(n):
	if i != h[a % 4]:
		if h[a % 4] == 'R':
			ans[0] += 1
		elif h[a % 4] == 'B':
			ans[1] += 1
		elif h[a % 4] == 'Y':
			ans[2] += 1
		elif h[a % 4] == 'G':
			ans[3] += 1
print(*ans)


def codeforces(lamps):
	boxes = [0, 0, 0, 0]
	names = [None, None, None, None]
	for (num, lamp) in enumerate(lamps):
		if lamp == '!':
			boxes[num % 4] += 1
		else:
			names[num % 4] = lamp
	order = ['R', 'B', 'Y', 'G']
	for i in range(len(names)):
		if names[i] is None:
			for name in order:
				if name not in names:
					names[i] = name
					break
	result = []
	for name in order:
		result.append(boxes[names.index(name)])
	return result
lamps = input()
result = map(str, codeforces(lamps))
print(' '.join(result))


s = input()
ss = [''] * len(s)
v = 'RBYG'
r = {'R': 0, 'G': 0, 'B': 0, 'Y': 0}
if len(s) >= 5:
	for i in list(v):
		j = 0
		while i != s[j]:
			j += 1
		t = j
		while j < len(s):
			ss[j] = i
			j += 4
		while t >= 0:
			ss[t] = i
			t -= 4
	for i in range(len(s)):
		if s[i] != ss[i] and s[i] == '!':
			r[ss[i]] = r[ss[i]] + 1
	for i in v:
		print(r[i], end=' ')
else:
	for i in v:
		if i not in s:
			print(1, end=' ')
		else:
			print(0, end=' ')


l = list(input())
r = l.index('R') % 4
b = l.index('B') % 4
y = l.index('Y') % 4
g = l.index('G') % 4
ans = [0, 0, 0, 0]
for i in range(len(l)):
	if l[i] == '!':
		if i % 4 == r:
			ans[0] += 1
		elif i % 4 == b:
			ans[1] += 1
		elif i % 4 == y:
			ans[2] += 1
		else:
			ans[3] += 1
print(' '.join(map(str, ans)))


s = input()
dct = {}
R = s.find('R') % 4
dct[R] = 0
G = s.find('G') % 4
dct[G] = 0
B = s.find('B') % 4
dct[B] = 0
Y = s.find('Y') % 4
dct[Y] = 0
for x in range(len(s)):
	if s[x] == '!':
		dct[x % 4] += 1
print(dct[R], dct[B], dct[Y], dct[G])


line = input()
alph = {'R': 0, 'B': 1, 'Y': 2, 'G': 3}
a = [[-1, 0], [-1, 0], [-1, 0], [-1, 0]]
for i in range(len(line)):
	c = i % 4
	if line[i] == '!':
		a[c][1] += 1
	else:
		a[c][0] = alph[line[i]]
a.sort()
print(a[0][1], a[1][1], a[2][1], a[3][1])


g = input()
c1 = g[0::4]
c2 = g[1::4]
c3 = g[2::4]
c4 = g[3::4]
colors = ['R', 'B', 'Y', 'G']
broken1 = 0
broken2 = 0
broken3 = 0
broken4 = 0
letters = []
for item in c1:
	if item == '!':
		broken1 += 1
	elif item not in letters:
		letters.append(item)
for item in c2:
	if item == '!':
		broken2 += 1
	elif item not in letters:
		letters.append(item)
for item in c3:
	if item == '!':
		broken3 += 1
	elif item not in letters:
		letters.append(item)
for item in c4:
	if item == '!':
		broken4 += 1
	elif item not in letters:
		letters.append(item)
answer = {letters[0]: broken1, letters[1]: broken2, letters[2]: broken3, letters[3]: broken4}
print(answer['R'], answer['B'], answer['Y'], answer['G'])


string = input()
count = [0, 0, 0, 0]
lights = ['', '', '', '']
for i in range(0, len(string)):
	count[i % 4] += 1
for i in range(0, 4):
	for j in range(i, len(string), 4):
		if string[j] != '!':
			count[i] -= 1
			lights[i] = string[j]
result = ''
for i in range(0, 4):
	if lights[i] == 'R':
		result += str(count[i]) + ' '
for i in range(0, 4):
	if lights[i] == 'B':
		result += str(count[i]) + ' '
for i in range(0, 4):
	if lights[i] == 'Y':
		result += str(count[i]) + ' '
for i in range(0, 4):
	if lights[i] == 'G':
		result += str(count[i])
print(result)


from itertools import permutations, cycle
s = input()
n = len(s)
for p in permutations('RBYG', 4):
	flag = True
	d = {'R': 0, 'G': 0, 'B': 0, 'Y': 0}
	for (x, y) in zip(s, cycle(p)):
		if x == '!':
			d[y] += 1
		elif x != y:
			flag = False
			break
	if flag:
		print(d['R'], d['B'], d['Y'], d['G'])
		break


s = input()
for i in [s.index(x) % 4 for x in 'RBYG']:
	print(s[i::4].count('!'))


l = input()
(r, g, b, y) = (0, 0, 0, 0)
s = []
for i in l:
	s.append(i)
while '!' in s:
	for i in range(len(s)):
		if s[i] == '!' and i < len(s) - 4 and (s[i + 4] != '!'):
			s[i] = s[i + 4]
			if 'B' == s[i]:
				b += 1
			if 'Y' == s[i]:
				y += 1
			if 'G' == s[i]:
				g += 1
			if 'R' == s[i]:
				r += 1
		elif s[i] == '!' and i > 3 and (s[i - 4] != '!'):
			s[i] = s[i - 4]
			if 'B' == s[i]:
				b += 1
			if 'Y' == s[i]:
				y += 1
			if 'G' == s[i]:
				g += 1
			if 'R' == s[i]:
				r += 1
		elif s[i] == '!' and i < len(s) - 3:
			s1 = s[i:i + 4]
			c = s1.count('!')
			if c == 1:
				if 'B' not in s1:
					b += 1
					s[i] = 'B'
				elif 'Y' not in s1:
					y += 1
					s[i] = 'Y'
				elif 'G' not in s1:
					g += 1
					s[i] = 'G'
				elif 'R' not in s1:
					r += 1
					s[i] = 'R'
print(r, b, y, g)


import sys, math, string, bisect
input = sys.stdin.readline
from collections import deque
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
s = input().strip()
d = {'R': 0, 'G': 0, 'Y': 0, 'B': 0}
l = []
g = 0
for i in range(4):
	c = 0
	k = 0
	for j in range(i, len(s), 4):
		if s[j] == '!' and k == 0:
			c += 1
		if k == 1:
			if s[j] == '!':
				d[t] += 1
		elif s[j] in d.keys():
			d[s[j]] = c
			t = s[j]
			k = 1
	if k == 0:
		l.append(c)
		g += 1
p = 0
if d['R'] == 0 and p < g:
	d['R'] = l[p]
	p += 1
if d['G'] == 0 and p < g:
	d['G'] = l[p]
	p += 1
if d['B'] == 0 and p < g:
	d['B'] = l[p]
	p += 1
if d['Y'] == 0 and p < g:
	d['Y'] = l[p]
	p += 1
print(d['R'], d['B'], d['Y'], d['G'])


def good(s1, s2):
	for i in range(3):
		if s1[i] != s2[i] and s2[i] != '!':
			return False
	if len(set(s1)) != len(s1):
		return False
	return True

def main():
	s = input()
	t = 'RGYB'
	for el1 in t:
		for el2 in t:
			for el3 in t:
				if good(el1 + el2 + el3, s):
					A = list(el1 + el2 + el3)
					for i in range(3, len(s)):
						ss = set((A[i - 3], A[i - 2], A[i - 1]))
						if s[i] in ss:
							break
						elif s[i] == '!':
							flag = True
							for elem in t:
								if elem not in ss:
									A.append(elem)
									flag = False
									break
							if flag:
								break
						else:
							A.append(s[i])
					if len(A) == len(s):
						d = dict()
						for elem in t:
							d[elem] = 0
						for i in range(len(A)):
							if A[i] != s[i]:
								d[A[i]] += 1
						print(d['R'], d['B'], d['Y'], d['G'])
						return
main()


import sys
import math
import bisect

def solve(s):
	n = len(s)
	B = ['?'] * 4
	for i in range(n):
		if s[i] != '!':
			B[i % 4] = s[i]
	A = [0] * 4
	for i in range(n):
		if s[i] == '!':
			c = B[i % 4]
			if c == 'R':
				A[0] += 1
			elif c == 'B':
				A[1] += 1
			elif c == 'Y':
				A[2] += 1
			elif c == 'G':
				A[3] += 1
	return A

def main():
	s = input()
	ans = solve(s)
	print(' '.join(list((str(a) for a in ans))))
main()


s = input()
ce = s.count('!')
if ce == 0:
	print(0, 0, 0, 0)
else:
	fr = s.find('R') % 4
	fb = s.find('B') % 4
	fy = s.find('Y') % 4
	fg = s.find('G') % 4
	cr = cb = cy = cg = 0
	i = 0
	l = len(s)
	while i < l:
		if s[i] == '!':
			if i % 4 == fr:
				cr += 1
			if i % 4 == fb:
				cb += 1
			if i % 4 == fy:
				cy += 1
			if i % 4 == fg:
				cg += 1
		i += 1
	print(cr, cb, cy, cg)


s = input()
r = s.index('R') % 4
b = s.index('B') % 4
y = s.index('Y') % 4
g = s.index('G') % 4
l = [0, 0, 0, 0]
n = len(s)
for i in range(n):
	if s[i] == '!':
		l[i % 4] += 1
print('{0} {1} {2} {3}'.format(l[r], l[b], l[y], l[g]))


line = input()
res = [0, 0, 0, 0]
dic = {'R': 0, 'B': 0, 'G': 0, 'Y': 0}
for i in range(len(line)):
	if line[i] == '!':
		res[i % 4] += 1
	if line[i] == 'R':
		dic['R'] = i % 4
	if line[i] == 'G':
		dic['G'] = i % 4
	if line[i] == 'B':
		dic['B'] = i % 4
	if line[i] == 'Y':
		dic['Y'] = i % 4
print(str(res[dic['R']]) + ' ' + str(res[dic['B']]) + ' ' + str(res[dic['Y']]) + ' ' + str(res[dic['G']]))


s = input()
z = ['R', 'B', 'Y', 'G']
r = s.find('R')
ans = [0, 0, 0, 0]
for i in range(4):
	r = s.find(z[i])
	while r - 4 >= 0:
		r -= 4
	while r <= len(s) - 1:
		j = r
		if s[j] != z[i]:
			ans[i] += 1
		r += 4
ans = map(str, ans)
print(' '.join(ans))


garland = input()
R = garland.index('R')
B = garland.index('B')
Y = garland.index('Y')
G = garland.index('G')
indices = [R, B, Y, G]
ans = ''
for index in indices:
	ans += str(len(list(filter(lambda x: (index - x) % 4 == 0 and garland[x] == '!', range(0, len(garland)))))) + ' '
print(ans)


def main():
	s = list(input())
	index = {'R': 0, 'Y': 0, 'B': 0, 'G': 0}
	count = {'R': 0, 'Y': 0, 'B': 0, 'G': 0}
	color = ['R', 'Y', 'B', 'G']
	n = len(s)
	for i in range(n):
		if s[i] in index:
			index[s[i]] = i
	for i in range(n):
		if s[i] == '!':
			for j in color:
				if abs(i - index[j]) % 4 == 0:
					s[i] = index[j]
					count[j] += 1
	print(count['R'], end=' ')
	print(count['B'], end=' ')
	print(count['Y'], end=' ')
	print(count['G'], end=' ')
main()


s = list(input())
n = len(s)
indexes = [None] * 4
answer = {'R': 0, 'G': 0, 'B': 0, 'Y': 0}
for i in range(n):
	if s[i] != '!':
		indexes[i % 4] = s[i]
for i in range(n):
	new = indexes[i % 4]
	if new != s[i]:
		answer[new] += 1
print(answer['R'], answer['B'], answer['Y'], answer['G'])


bulbs = list(input())
posOfR = bulbs.index('R') % 4
posOfB = bulbs.index('B') % 4
posOfY = bulbs.index('Y') % 4
posOfG = bulbs.index('G') % 4
numofDeadR = 0
numofDeadB = 0
numofDeadY = 0
numofDeadG = 0
for i in [i for (i, letter) in enumerate(bulbs) if letter == '!']:
	if i % 4 == posOfR:
		numofDeadR += 1
	elif i % 4 == posOfB:
		numofDeadB += 1
	elif i % 4 == posOfY:
		numofDeadY += 1
	else:
		numofDeadG += 1
print(' '.join(map(str, [numofDeadR, numofDeadB, numofDeadY, numofDeadG])))


s = input()
a = [0] * 4
i = 0
while s[i] != 'R':
	i += 1
j = i
while j - 4 >= 0:
	if s[j - 4] == '!':
		a[0] += 1
	j = j - 4
while i + 4 < len(s):
	if s[i + 4] == '!':
		a[0] += 1
	i = i + 4
i = 0
while s[i] != 'B':
	i += 1
j = i
while j - 4 >= 0:
	if s[j - 4] == '!':
		a[1] += 1
	j = j - 4
while i + 4 < len(s):
	if s[i + 4] == '!':
		a[1] += 1
	i = i + 4
i = 0
while s[i] != 'Y':
	i += 1
j = i
while j - 4 >= 0:
	if s[j - 4] == '!':
		a[2] += 1
	j = j - 4
while i + 4 < len(s):
	if s[i + 4] == '!':
		a[2] += 1
	i = i + 4
i = 0
while s[i] != 'G':
	i += 1
j = i
while j - 4 >= 0:
	if s[j - 4] == '!':
		a[3] += 1
	j = j - 4
while i + 4 < len(s):
	if s[i + 4] == '!':
		a[3] += 1
	i = i + 4
print(a[0], a[1], a[2], a[3])


import sys
input = lambda : sys.stdin.readline().rstrip('\r\n')
s = input()
mat = []
ans = {'r': 0, 'b': 0, 'y': 0, 'g': 0}
for i in range(4):
	mat.append(s[i:len(s):4])
ok = False
for i in mat:
	if i.count('!') < len(i):
		ok = True
if ok:
	for i in mat:
		for j in i:
			if j != '!':
				ans[j.lower()] = i.count('!')
				break
for (k, v) in ans.items():
	print(v, end=' ')


s = input()
cnt = [0] * 4
ind = [0] * 4
for (i, ch) in enumerate(s):
	if ch == 'R':
		ind[0] = i % 4
	elif ch == 'B':
		ind[1] = i % 4
	elif ch == 'Y':
		ind[2] = i % 4
	elif ch == 'G':
		ind[3] = i % 4
	else:
		cnt[i % 4] += 1
print(*[cnt[ind[i]] for i in range(4)])


i = -1
mas0 = []
mas1 = []
mas2 = []
mas3 = []
mas = []
r = 0
b = 0
y = 0
g = 0
n = input()
for element in n:
	mas.append(element)
for element in mas:
	i += 1
	if i == 0 or i % 4 == 0:
		mas0.append(element)
	if i % 4 == 1:
		mas1.append(element)
	if i % 4 == 2:
		mas2.append(element)
	if i % 4 == 3:
		mas3.append(element)
if 'R' in mas0:
	for element in mas0:
		if element == '!':
			r += 1
elif 'R' in mas1:
	for element in mas1:
		if element == '!':
			r += 1
elif 'R' in mas2:
	for element in mas2:
		if element == '!':
			r += 1
elif 'R' in mas3:
	for element in mas3:
		if element == '!':
			r += 1
if 'B' in mas0:
	for element in mas0:
		if element == '!':
			b += 1
elif 'B' in mas1:
	for element in mas1:
		if element == '!':
			b += 1
elif 'B' in mas2:
	for element in mas2:
		if element == '!':
			b += 1
elif 'B' in mas3:
	for element in mas3:
		if element == '!':
			b += 1
if 'Y' in mas0:
	for element in mas0:
		if element == '!':
			y += 1
elif 'Y' in mas1:
	for element in mas1:
		if element == '!':
			y += 1
elif 'Y' in mas2:
	for element in mas2:
		if element == '!':
			y += 1
elif 'Y' in mas3:
	for element in mas3:
		if element == '!':
			y += 1
if 'G' in mas0:
	for element in mas0:
		if element == '!':
			g += 1
elif 'G' in mas1:
	for element in mas1:
		if element == '!':
			g += 1
elif 'G' in mas2:
	for element in mas2:
		if element == '!':
			g += 1
elif 'G' in mas3:
	for element in mas3:
		if element == '!':
			g += 1
print(r, b, y, g)


s = input()
string = list(s)
cnt = {'R': 0, 'B': 0, 'Y': 0, 'G': 0}
length = len(string)
for i in range(length):
	if string[i] != '!':
		pos = i + 4
		while pos < length:
			if string[pos] == '!':
				cnt[string[i]] += 1
				string[pos] = string[i]
			pos += 4
		pos = i - 4
		while pos >= 0:
			if string[pos] == '!':
				cnt[string[i]] += 1
				string[pos] = string[i]
			pos -= 4
print(str(cnt['R']) + ' ' + str(cnt['B']) + ' ' + str(cnt['Y']) + ' ' + str(cnt['G']))


str = input()
colors = {'R': 0, 'B': 1, 'Y': 2, 'G': 3}
n = len(str)
who = ['!'] * 4
for i in range(n):
	mod = i % 4
	if str[i] != '!':
		if who[mod] == '!':
			who[mod] = str[i]
		else:
			assert who[mod] == str[i]
ans = [0] * 4
for i in range(n):
	mod = i % 4
	if str[i] == '!':
		ans[colors[who[mod]]] += 1
for x in ans:
	print('%d ' % x, end='')


import sys
from math import sqrt, gcd, ceil, log
from bisect import bisect
from collections import defaultdict
inp = sys.stdin.readline
read = lambda : list(map(int, inp().strip().split()))

def solve():
	s = input()
	dic = {i: 0 for i in range(4)}
	col = defaultdict(int)
	for i in range(len(s)):
		if s[i] == '!':
			dic[i % 4] += 1
		else:
			col[s[i]] = i % 4
	for i in ['R', 'B', 'Y', 'G']:
		print(dic[col[i]], end=' ')
solve()


s = input() + '   '
(d, ans, DD) = ({}, 0, {'R': 0, 'B': 0, 'Y': 0, 'G': 0})
for i in range(len(s)):
	if s[i] in 'RGBY':
		d[i % 4] = s[i]
for i in range(len(s)):
	if s[i] == '!':
		DD[d[i % 4]] += 1
print(DD['R'], DD['B'], DD['Y'], DD['G'])


from collections import defaultdict
s = input()
l = [None] * 4
ans = defaultdict(int)
for i in range(len(s)):
	if s[i] != '!':
		l[i % 4] = s[i]
for i in range(len(s)):
	if s[i] == '!':
		ans[l[i % 4]] += 1
print(ans['R'], ans['B'], ans['Y'], ans['G'])


def list_from_input():
	return list(map(int, input().split()))

def solve(garland):
	n = 4
	pattern = [None] * n
	chunks = [garland[i:i + n] for i in range(0, len(garland), n)]
	for i in range(n):
		j = 0
		while pattern[i] is None:
			if chunks[j][i] != '!':
				pattern[i] = chunks[j][i]
			j += 1
	lamps = {'R': 0, 'B': 0, 'Y': 0, 'G': 0}
	for chunk in chunks:
		for j in range(len(chunk)):
			if chunk[j] != pattern[j]:
				lamps[pattern[j]] += 1
	return lamps

def main():
	garland = input()
	lamps = solve(garland)
	print('{} {} {} {}'.format(lamps['R'], lamps['B'], lamps['Y'], lamps['G']))
main()


from sys import stdin, stdout
garland = list(stdin.readline()[:-1])
disabled = garland.count('!')
(kr, kb, ky, kg) = (0, 0, 0, 0)
order = ['R', 'B', 'Y', 'G']

def map_colors_to_pos(garland):
	mapping = {}
	for (num, lamp) in enumerate(garland):
		if lamp != '!':
			mapping[num % 4] = lamp
		if len(mapping) > 3:
			break
	return mapping

def count_broken_lamp(garland, mapping):
	replace_count = {}
	for (num, lamp) in enumerate(garland):
		if lamp == '!':
			replace_count[mapping[num % 4]] = replace_count.get(mapping[num % 4], 0) + 1
	return replace_count

def form_answer(replace_count, order):
	result = ' '.join([str(replace_count.get(lamp, 0)) for lamp in order])
	return result
mapping = map_colors_to_pos(garland)
replace = count_broken_lamp(garland, mapping)
stdout.write(form_answer(replace, order))


from collections import Counter
s = input()
a = {s.index('R') % 4: 'R', s.index('Y') % 4: 'Y', s.index('B') % 4: 'B', s.index('G') % 4: 'G'}
d = Counter()
for (i, c) in enumerate(s):
	if c == '!':
		d[a[i % 4]] += 1
print(d['R'], d['B'], d['Y'], d['G'])


s = input()
arr = []
n = len(s)
flag1 = flag2 = flag3 = flag4 = 0
count1 = count2 = count3 = count4 = 0
for i in range(0, n, 4):
	if s[i] != '!' and flag1 == 0:
		arr.append(s[i])
		flag1 = 1
	elif s[i] == '!':
		count1 += 1
if flag1 == 0:
	arr.append('!')
for i in range(1, n, 4):
	if s[i] != '!' and flag2 == 0:
		arr.append(s[i])
		flag2 = 1
	elif s[i] == '!':
		count2 += 1
if flag2 == 0:
	arr.append('!')
for i in range(2, n, 4):
	if s[i] != '!' and flag3 == 0:
		arr.append(s[i])
		flag3 = 1
	elif s[i] == '!':
		count3 += 1
if flag3 == 0:
	arr.append('!')
for i in range(3, n, 4):
	if s[i] != '!' and flag4 == 0:
		arr.append(s[i])
		flag4 = 1
	elif s[i] == '!':
		count4 += 1
if flag4 == 0:
	arr.append('!')
dic = {}
dic[arr[0]] = count1
dic[arr[1]] = count2
dic[arr[2]] = count3
dic[arr[3]] = count4
print(dic['R'], dic['B'], dic['Y'], dic['G'])


(s, d) = (input(), {'R': 0, 'B': 0, 'Y': 0, 'G': 0})
for i in range(4):
	a = s[i::4]
	b = a.replace('!', '')
	d[b[0]] = len(a) - len(b)
print('{R} {B} {Y} {G}'.format(**d))


s = input()
s = list(s)
n = len(s)
r = 0
b = 0
y = 0
g = 0
i1 = s.index('R')
j1 = i1
f1 = 0
f2 = 0
while True:
	if i1 + 4 < n:
		i1 += 4
		if s[i1] == '!':
			s[i1] = 'R'
			r += 1
	else:
		f1 = 1
	if j1 - 4 >= 0:
		j1 -= 4
		if s[j1] == '!':
			s[j1] = 'R'
			r += 1
	else:
		f2 = 1
	if f1 == 1 and f2 == 1:
		break
i1 = s.index('B')
j1 = i1
f1 = 0
f2 = 0
while True:
	if i1 + 4 < n:
		i1 += 4
		if s[i1] == '!':
			s[i1] = 'B'
			b += 1
	else:
		f1 = 1
	if j1 - 4 >= 0:
		j1 -= 4
		if s[j1] == '!':
			s[j1] = 'B'
			b += 1
	else:
		f2 = 1
	if f1 == 1 and f2 == 1:
		break
i1 = s.index('Y')
j1 = i1
f1 = 0
f2 = 0
while True:
	if i1 + 4 < n:
		i1 += 4
		if s[i1] == '!':
			s[i1] = 'Y'
			y += 1
	else:
		f1 = 1
	if j1 - 4 >= 0:
		j1 -= 4
		if s[j1] == '!':
			s[j1] = 'Y'
			y += 1
	else:
		f2 = 1
	if f1 == 1 and f2 == 1:
		break
i1 = s.index('G')
j1 = i1
f1 = 0
f2 = 0
while True:
	if i1 + 4 < n:
		i1 += 4
		if s[i1] == '!':
			s[i1] = 'G'
			g += 1
	else:
		f1 = 1
	if j1 - 4 >= 0:
		j1 -= 4
		if s[j1] == '!':
			s[j1] = 'G'
			g += 1
	else:
		f2 = 1
	if f1 == 1 and f2 == 1:
		break
print(r, b, y, g, end=' ')


import sys
from collections import Counter

def truecolors(xs):
	length = len(xs)
	cols = ['R', 'B', 'Y', 'G']
	c_pos = {}
	cnt = Counter()
	for col in cols:
		c_pos[xs.index(col) % 4] = col
	for id in range(length):
		if xs[id] == '!':
			cnt[c_pos[id % 4]] += 1
	out = '{} {} {} {}'.format(cnt['R'], cnt['B'], cnt['Y'], cnt['G'])
	print(out)

def solution():
	first_line = sys.stdin.readline()
	xlights = [ch for ch in first_line.strip()]
	truecolors(xlights)
solution()


g = input()
l_c = [''] * 4
for i in range(len(g)):
	if g[i] != '!':
		l_c[i % 4] = g[i]
d_c = {}
d_c['R'] = 0
d_c['G'] = 0
d_c['B'] = 0
d_c['Y'] = 0
for i in range(len(g)):
	if g[i] == '!':
		d_c[l_c[i % 4]] += 1
print('%d %d %d %d' % (d_c['R'], d_c['B'], d_c['Y'], d_c['G']))


s = input()
ans = [0] * 4
a = b = c = d = 0
for i in range(len(s)):
	if s[i] == 'R':
		a = i % 4
	elif s[i] == 'B':
		b = i % 4
	elif s[i] == 'Y':
		c = i % 4
	elif s[i] == 'G':
		d = i % 4
	else:
		ans[i % 4] += 1
print(ans[a], ans[b], ans[c], ans[d])


s = input()
indr = s.index('R') % 4
sumr = sum((c == '!' for c in s[indr::4]))
indb = s.index('B') % 4
sumb = sum((c == '!' for c in s[indb::4]))
indy = s.index('Y') % 4
sumy = sum((c == '!' for c in s[indy::4]))
indg = s.index('G') % 4
sumg = sum((c == '!' for c in s[indg::4]))
print(sumr, sumb, sumy, sumg)


s = input()
n = len(s)
o = n % 4
ndiv4 = n // 4
r = (s.find('R') + 1) % 4
g = (s.find('G') + 1) % 4
b = (s.find('B') + 1) % 4
y = (s.find('Y') + 1) % 4
rn1 = ndiv4 if r > o or r == 0 else ndiv4 + 1
gn1 = ndiv4 if g > o or g == 0 else ndiv4 + 1
bn1 = ndiv4 if b > o or b == 0 else ndiv4 + 1
yn1 = ndiv4 if y > o or y == 0 else ndiv4 + 1
rn = s.count('R')
gn = s.count('G')
bn = s.count('B')
yn = s.count('Y')
print(rn1 - rn, bn1 - bn, yn1 - yn, gn1 - gn)


a = str(input(''))
a1 = ''
a2 = ''
a3 = ''
a4 = ''
n = 0
while n < len(a):
	a1 += a[n]
	n += 4
n = 1
while n < len(a):
	a2 += a[n]
	n += 4
n = 2
while n < len(a):
	a3 += a[n]
	n += 4
n = 3
while n < len(a):
	a4 += a[n]
	n += 4
b1 = 0
b2 = 0
b3 = 0
b4 = 0
for i in range(len(a1)):
	if a1[i] == '!':
		b1 += 1
for i in range(len(a2)):
	if a2[i] == '!':
		b2 += 1
for i in range(len(a3)):
	if a3[i] == '!':
		b3 += 1
for i in range(len(a4)):
	if a4[i] == '!':
		b4 += 1
f = [0, 0, 0, 0]
if 'R' in a1:
	f[0] = b1
elif 'R' in a2:
	f[0] = b2
elif 'R' in a3:
	f[0] = b3
elif 'R' in a4:
	f[0] = b4
if 'B' in a1:
	f[1] = b1
elif 'B' in a2:
	f[1] = b2
elif 'B' in a3:
	f[1] = b3
elif 'B' in a4:
	f[1] = b4
if 'Y' in a1:
	f[2] = b1
elif 'Y' in a2:
	f[2] = b2
elif 'Y' in a3:
	f[2] = b3
elif 'Y' in a4:
	f[2] = b4
if 'G' in a1:
	f[3] = b1
elif 'G' in a2:
	f[3] = b2
elif 'G' in a3:
	f[3] = b3
elif 'G' in a4:
	f[3] = b4
for i in range(len(f)):
	print(f[i])


import sys

def main():
	s = sys.stdin.readline()
	s = [c for c in s]
	a = {}
	for letter in ['R', 'B', 'Y', 'G']:
		a[letter] = 0
		ind = s.index(letter)
		if ind >= 4:
			for i in range(ind, -1, -4):
				if s[i] == '!':
					s[i] = letter
					a[letter] += 1
		if len(s) - ind > 4:
			for i in range(ind, len(s), 4):
				if s[i] == '!':
					s[i] = letter
					a[letter] += 1
	print(a['R'], a['B'], a['Y'], a['G'])
main()


from math import inf, sqrt, floor, ceil
from collections import Counter, defaultdict, deque
from heapq import heappush as hpush, heappop as hpop, heapify as h
from operator import itemgetter
from itertools import product
from bisect import bisect_left, bisect_right
s = input()
d = {}
n = len(s)
for i in range(n):
	if s[i] != '!':
		d[i % 4] = s[i]
ans = defaultdict(int)
for i in range(n):
	if s[i] == '!':
		ans[d[i % 4]] += 1
res = []
res.append(ans['R'])
res.append(ans['B'])
res.append(ans['Y'])
res.append(ans['G'])
print(*res)


s = list(map(str, input()))
p = ''.join((str(x) for x in s))
mp = {'R': 0, 'B': 1, 'Y': 2, 'G': 3}
ans = [0, 0, 0, 0]
ind = 0
if '!' * len(s) == p:
	(ar, ay, ab, ag) = (n // 4, n // 4, n // 4, n // 4)
	if n % 4 == 1:
		ar += 1
	if n % 4 == 2:
		ar += 1
		ay += 1
	if n % 4 == 3:
		ar += 1
		ay += 1
		ab += 1
	print(ar, ab, ay, ag)
else:
	n = len(s)
	for i in range(n):
		if s[i] != '!':
			for j in range(i, n, 4):
				if s[j] != s[i]:
					s[j] = s[i]
					ans[mp[s[i]]] += 1
			for j in range(i, -1, -4):
				if s[j] != s[i]:
					s[j] = s[i]
					ans[mp[s[i]]] += 1
	print(*ans)


def main():
	s = input()
	mp = [0 for i in range(4)]
	ch = {'R': 0, 'B': 1, 'Y': 2, 'G': 3}
	for i in range(len(s)):
		if s[i] != '!':
			mp[i % 4] = ch[s[i]]
	ans = [0 for i in range(4)]
	for i in range(len(s)):
		if s[i] == '!':
			ans[mp[i % 4]] += 1
	for x in ans:
		print(x, end=' ')
	print()
main()


inp = str(input())
colors = list(inp)
r = 0
b = 0
g = 0
y = 0
for j in range(0, 4):
	cnt = 0
	color = 0
	for i in range(j, len(colors), 4):
		if colors[i] == '!':
			cnt += 1
		else:
			color = colors[i]
	if color == 'R':
		r = cnt
	elif color == 'B':
		b = cnt
	elif color == 'G':
		g = cnt
	elif color == 'Y':
		y = cnt
print(r, ' ', b, ' ', y, ' ', g)


s = input()
(pr, pb, pg, py) = (-1, -1, -1, -1)
(r, b, g, y) = (0, 0, 0, 0)
(kr, kb, ky, kg) = (0, 0, 0, 0)
for (i, ch) in enumerate(s):
	if ch == 'R' and r == 0:
		pr = i + 1
		r = 1
	if ch == 'B' and b == 0:
		pb = i + 1
		b = 1
	if ch == 'G' and g == 0:
		pg = i + 1
		g = 1
	if ch == 'Y' and y == 0:
		py = i + 1
		y = 1
if pr > 4:
	if pr % 4 != 0:
		pr = pr % 4
	else:
		pr = 4
if pb > 4:
	if pb % 4 != 0:
		pb = pb % 4
	else:
		pb = 4
if py > 4:
	if py % 4 != 0:
		py = py % 4
	else:
		py = 4
if pg > 4:
	if pg % 4 != 0:
		pg = pg % 4
	else:
		pg = 4
for i in range(pr - 1, len(s), 4):
	if s[i] == '!':
		kr += 1
for i in range(pb - 1, len(s), 4):
	if s[i] == '!':
		kb += 1
for i in range(py - 1, len(s), 4):
	if s[i] == '!':
		ky += 1
for i in range(pg - 1, len(s), 4):
	if s[i] == '!':
		kg += 1
print('{0} {1} {2} {3}'.format(kr, kb, ky, kg))


l = list('RBYG')
inds = []
s = input()
later = None
n = len(s)
ans = [0] * len(l)
for i in range(len(l)):
	inds.append(s.find(l[i]))
	if inds[i] == -1:
		later = i
		continue
	curr = inds[i] % len(l)
	while curr < n:
		if s[curr] == '!':
			ans[i] += 1
		curr += len(l)
if later:
	tmp_sum = 0
	for i in range(len(l)):
		if i != later:
			tmp_sum += inds[i] % len(l)
	curr = sum(range(len(l))) - tmp_sum
	while curr < n:
		if s[curr] == '!':
			ans[later] += 1
		curr += len(l)
print(' '.join(map(str, ans)))


x = input()
n = len(x)
letters = ['R', 'B', 'Y', 'G']

def perm(n):
	if n == 1:
		return ['R', 'B', 'Y', 'G']
	else:
		l = ['R', 'B', 'Y', 'G']
		ans = []
		for i in perm(n - 1):
			for j in l:
				if not j in i:
					ans.append(i + j)
	return ans
r = n % 4
q = n // 4
ans = ''
for i in perm(4):
	possible = i * q + i[:r]
	check = True
	for i in range(n):
		if x[i] != '!':
			if x[i] != possible[i]:
				check = False
				break
	if check == True:
		ans = possible
		break
L1 = [0, 0, 0, 0]
L2 = [0, 0, 0, 0]
for i in x:
	if i != '!':
		L1[letters.index(i)] += 1
for i in ans:
	L2[letters.index(i)] += 1
for i in range(0, 4):
	print(L2[i] - L1[i], end=' ')


garland = input()
lamps = 'RBYG'
pos = {}
k = {}
for lamp in lamps:
	for i in range(len(garland)):
		if garland[i] == lamp:
			pos[lamp] = pos.get(lamp, i)
for lamp in lamps:
	p = pos[lamp]
	k[lamp] = k.get(lamp, 0)
	for i in range(p, len(garland), 4):
		if garland[i] != lamp:
			k[lamp] += 1
	for i in range(p, -1, -4):
		if garland[i] != lamp:
			k[lamp] += 1
for lamp in lamps:
	print(k[lamp], end=' ')


s = list(input())
ans = {'R': 0, 'B': 0, 'Y': 0, 'G': 0}
for (i, ch) in enumerate(s):
	if ch != '!':
		for j in range(i, len(s), 4):
			if s[j] == '!':
				s[j] = ch
				ans[ch] += 1
		for j in range(i, -1, -4):
			if s[j] == '!':
				s[j] = ch
				ans[ch] += 1
print(ans['R'], ans['B'], ans['Y'], ans['G'])


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
map_gir = {}
map_rotas = {'R': 0, 'B': 0, 'Y': 0, 'G': 0}
entry = insr()
index = 0
while len(map_gir) < 4:
	if not entry[index] in map_gir and entry[index] != '!':
		map_gir[index % 4] = entry[index]
	index += 1
index = 0
for e in entry:
	if entry[index] == '!':
		map_rotas[map_gir[index % 4]] += 1
	index += 1
print(map_rotas['R'], ' ', map_rotas['B'], ' ', map_rotas['Y'], ' ', map_rotas['G'])


string = input()
l = []
for each in range(0, len(string), 4):
	l.append(string[each:each + 5])
seq = ''
for each in range(0, 4):
	for ele in l:
		if ele[each] != '!':
			seq += ele[each]
			break
kr = kb = ky = kg = 0
for each in range(0, len(string)):
	if string[each] == '!':
		pos = each % 4
		update = seq[pos]
		if update == 'R':
			kr += 1
		elif update == 'Y':
			ky += 1
		elif update == 'G':
			kg += 1
		elif update == 'B':
			kb += 1
print(kr, kb, ky, kg)


s = list(input())
n = len(s)
t = ['R', 'B', 'Y', 'G']
res = [0 for i in range(4)]

def update(c, p):
	for i in range(p + 4, n, 4):
		if s[i] == '!':
			s[i] = t[c]
			res[c] += 1
	for i in range(p - 4, -1, -4):
		if s[i] == '!':
			s[i] = t[c]
			res[c] += 1
for i in range(4):
	for j in range(n):
		if s[j] == t[i]:
			update(i, j)
print(' '.join(map(str, res)))


inp = str(input())
res = [0, 0, 0, 0]
rbyg = [-1, -1, -1, -1]
for i in range(len(inp)):
	try:
		rbyg['RBYG'.index(inp[i])] = i % 4
	except:
		res[i % 4] += 1
print(res[rbyg[0]], res[rbyg[1]], res[rbyg[2]], res[rbyg[3]], sep=' ')


st = input()
a = []
a.append(st[0::4])
a.append(st[1::4])
a.append(st[2::4])
a.append(st[3::4])
d = {'R': -1, 'B': -1, 'Y': -1, 'G': -1, '#': -1}
for i in range(0, 4):
	c = '#'
	num = 0
	for x in a[i]:
		if x == '!':
			num += 1
		else:
			c = x
	d[c] = num
if d['R'] == -1:
	d['R'] = d['#']
if d['B'] == -1:
	d['B'] = d['#']
if d['Y'] == -1:
	d['Y'] = d['#']
if d['G'] == -1:
	d['G'] = d['#']
print(d['R'], d['B'], d['Y'], d['G'])


state = input()
order = {'R': -1, 'B': -1, 'Y': -1, 'G': -1}
for (i, current) in enumerate(state):
	if current != '!':
		order[current] = i % 4

def search(color):
	result = 0
	for (i, current) in enumerate(state):
		if current == '!' and i % 4 == order[color]:
			result += 1
	return result
s = search
print(s('R'), s('B'), s('Y'), s('G'), sep=' ')


s = input()
if '!' not in s:
	print('0', '0', '0', '0')
else:
	r = s.index('R') % 4
	b = s.index('B') % 4
	y = s.index('Y') % 4
	g = s.index('G') % 4
	(a, c, e, f) = (0, 0, 0, 0)
	for i in range(len(s)):
		if s[i] == '!':
			d = i % 4
			if d == r:
				a = a + 1
			elif d == b:
				c = c + 1
			elif d == y:
				e = e + 1
			else:
				f = f + 1
	print(a, c, e, f)


import sys
import math
import itertools
import collections

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	newnumber = 0
	while number > 0:
		newnumber += number % base
		number //= base
	return newnumber

def cdiv(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def wr(arr):
	return ' '.join(map(str, arr))

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)
colors = {'B', 'G', 'R', 'Y'}
ans = {'R': 0, 'B': 0, 'Y': 0, 'G': 0}
pos = {'R': 0, 'B': 0, 'Y': 0, 'G': 0}
s = list(input())
for c in colors:
	pos[c] = s.index(c) % 4
for c in colors:
	for i in range(pos[c], len(s), 4):
		if s[i] == '!':
			ans[c] += 1
print(wr(ans.values()))


garland = input()
R = garland.index('R')
B = garland.index('B')
Y = garland.index('Y')
G = garland.index('G')
indices = [R, B, Y, G]
ans = ''
for index in indices:
	ans += str(len([x for x in range(0, len(garland)) if (x - index) % 4 == 0 and garland[x] == '!'])) + ' '
print(ans)


ch = input()
t = []
m = []
n = []
k = 0
ch1 = ''
i = 0
a = len(ch) // 4 * 4
while i < a:
	ch1 = ch[i:i + 4]
	t.append(ch1)
	i = i + 4
	ch1 = ''
ch2 = ch[a:len(ch)]
i = 0
for i in range(4 - len(ch2)):
	ch2 = ch2 + '*'
t.append(ch2)
i = 0
for j in range(4):
	i = 0
	while t[i][j] in ['!', '*'] and i < len(t) - 1:
		i = i + 1
	if not t[i][j] in ['!', '*']:
		m.append(t[i][j])
	else:
		m.append('!')
	s = 0
	ch2 = 0
	for k in range(len(t)):
		if t[k][j] == '!':
			s = s + 1
	ch2 = m[j] + str(s)
	n.append(ch2)
n.sort()
b = n[0]
c = n[1]
d = n[2]
e = n[3]
n[0] = d
n[1] = b
n[2] = e
n[3] = c
ch3 = ''
for i in range(4):
	ch3 = ch3 + n[i][1:] + ' '
print(ch3[:len(ch3) - 1])


s = input()
m = {}
for i in range(len(s)):
	if s[i] != '!':
		m[i % 4] = s[i]
c = {'R': 0, 'B': 0, 'Y': 0, 'G': 0}
for i in range(len(s)):
	if s[i] == '!':
		c[m[i % 4]] += 1
print(c['R'], c['B'], c['Y'], c['G'])


indxs = {0: 0, 1: 0, 2: 0, 3: 0}
colors = {'R': -1, 'G': -1, 'B': -1, 'Y': -1}
garland = input()

def buildDict(idx, val):
	idx = idx % 4
	if val == '!':
		indxs[idx] += 1
	elif colors[val] == -1:
		colors[val] = idx
[buildDict(idx, val) for (idx, val) in enumerate(garland)]
print(' '.join((str(n) for n in [indxs[colors['R']], indxs[colors['B']], indxs[colors['Y']], indxs[colors['G']]])))


s = input()
if s.count('!') == 0:
	print('0 0 0 0')
else:
	kr = kb = ky = kg = 0
	l = len(s)
	k = [0, 0, 0, 0]
	for i in range(l):
		if s[i] != '!':
			j = i % 4
			k[j] = s[i]
	for i in range(l):
		if s[i] == '!':
			j = k[i % 4]
			if j == 'R':
				kr += 1
			if j == 'B':
				kb += 1
			if j == 'Y':
				ky += 1
			if j == 'G':
				kg += 1
	print('{} {} {} {}'.format(kr, kb, ky, kg))


def f(list4):
	col = ['R', 'B', 'Y', 'G']
	a = list4.index('!')
	for j in col:
		if j not in list4:
			list4[a] = j
	return list4
s = str(input())
l = list(s)
list1 = ['R', 'B', 'Y', 'G']
list2 = [-1, -1, -1, -1]
ans = [0, 0, 0, 0]
for i in range(len(s)):
	if s[i] == 'R':
		list2[0] = i % 4
	elif s[i] == 'B':
		list2[1] = i % 4
	elif s[i] == 'Y':
		list2[2] = i % 4
	elif s[i] == 'G':
		list2[3] = i % 4
	if list2.count(-1) == 0:
		break
ans1 = [0 for i in range(len(s))]
for i in range(len(s)):
	a = list2.index(i % 4)
	ans1[i] = list1[a]
ans[0] = ans1.count('R') - l.count('R')
ans[1] = ans1.count('B') - l.count('B')
ans[2] = ans1.count('Y') - l.count('Y')
ans[3] = ans1.count('G') - l.count('G')
print(*ans)


S = input()
D = {}
for i in range(len(S)):
	if S[i] != '!':
		D[i % 4] = [S[i], 0]
for i in range(len(S)):
	if S[i] == '!':
		D[i % 4][1] += 1
L = {}
for i in D:
	L[D[i][0]] = D[i][1]
print(L['R'], L['B'], L['Y'], L['G'])


s = input()
count = {'R': 0, 'B': 0, 'Y': 0, 'G': 0}
four = ['!', '!', '!', '!']
for i in range(4):
	if s[i] == '!':
		m = i + 4
		while m < len(s):
			if s[m] != '!':
				four[i] = s[m]
				count[four[i]] += 1
				break
			m += 4
	else:
		four[i] = s[i]
for i in range(4, len(s)):
	if s[i] == '!':
		count[four[i % 4]] += 1
print(count['R'], count['B'], count['Y'], count['G'])


import logging
fmt = '%(levelname)s - %(name)s (line:%(lineno)s) - %(message)s'
formatter = logging.Formatter(fmt)
ch = logging.StreamHandler()
ch.setLevel(logging.ERROR)
ch.setFormatter(formatter)
logger = logging.getLogger('blown_garland')
logger.setLevel(logging.ERROR)
logger.addHandler(ch)

def solve(s):
	if '!' not in s:
		return (0, 0, 0, 0)
	(r, b, y, g) = (s.index('R'), s.index('B'), s.index('Y'), s.index('G'))
	(r, b, y, g) = (r % 4, b % 4, y % 4, g % 4)
	colors = [0] * 4
	for (i, c) in enumerate(s):
		if c == '!':
			colors[i % 4] += 1
	ans = []
	for i in [r, b, y, g]:
		ans.append(colors[i])
	return ans

def main():
	s = input().strip()
	result = solve(s)
	print(' '.join(map(str, result)))
main()


s = input()
(r, b, y, g) = (-1, -1, -1, -1)
ones = [0, 0, 0, 0]
for (i, c) in enumerate(s):
	if c == 'R' and r == -1:
		r = i % 4
	if c == 'G' and g == -1:
		g = i % 4
	if c == 'Y' and y == -1:
		y = i % 4
	if c == 'B' and b == -1:
		b = i % 4
	if c == '!':
		ones[i % 4] += 1
print(str(ones[r]) + ' ' + str(ones[b]) + ' ' + str(ones[y]) + ' ' + str(ones[g]))


a = input()
t1 = 0
t2 = 0
t3 = 0
t4 = 0
ind1 = 0
ind2 = 0
ind3 = 0
ind4 = 0
for j in range(len(a)):
	if a[j] == 'R':
		ind1 = j % 4
	if a[j] == 'B':
		ind2 = j % 4
	if a[j] == 'Y':
		ind3 = j % 4
	if a[j] == 'G':
		ind4 = j % 4
for j in range(len(a)):
	if a[j] == '!':
		if j % 4 == ind1:
			t1 += 1
		elif j % 4 == ind2:
			t2 += 1
		elif j % 4 == ind3:
			t3 += 1
		else:
			t4 += 1
print(t1, t2, t3, t4)


S = input()
N = len(S)
d = {}
for i in range(N):
	if S[i] != '!':
		d[i % 4] = S[i]
ans = {}
for i in range(N):
	if S[i] == '!':
		ans[d[i % 4]] = ans.get(d[i % 4], 0) + 1
anss = [ans[s] if s in ans else 0 for s in 'RBYG']
print(' '.join(map(str, anss)))


colors = set('RGBY'.split())
s = input()
(r, g, b, y) = (0, 0, 0, 0)
(R, G, B, Y) = (-1, -1, -1, -1)
for i in range(len(s)):
	if s[i] == 'R':
		R = i % 4
	elif s[i] == 'G':
		G = i % 4
	elif s[i] == 'B':
		B = i % 4
	else:
		Y = i % 4
for i in range(len(s)):
	if s[i] == '!':
		if i % 4 == R:
			r += 1
		elif i % 4 == G:
			g += 1
		elif i % 4 == B:
			b += 1
		else:
			y += 1
print(r, b, y, g)


n = list(input())
tad = []
p = n.index('R') + 1
w = n.index('B') + 1
l = n.index('Y') + 1
o = n.index('G') + 1
tad.append(p % 4)
tad.append(w % 4)
tad.append(l % 4)
tad.append(o % 4)
tad[tad.index(0)] = 4
op = 0
k = 0
lo = 0
pod = []
tom = tad[op] - 1
tad.append(0)
for x in range(555555):
	if tom < len(n):
		if n[tom] == '!':
			lo += 1
			tom += 4
		else:
			tom += 4
	else:
		pod.append(lo)
		lo = 0
		op += 1
		tom = tad[op] - 1
	if len(pod) >= 4:
		print(*pod[0:4])
		break


a = input()
(g, p) = ({}, {'R': 0, 'B': 0, 'Y': 0, 'G': 0})
for i in range(len(a)):
	if a[i] in 'BYRG':
		g[i % 4] = a[i]
for i in range(len(a)):
	if a[i] == '!':
		p[g[i % 4]] += 1
print(p['R'], p['B'], p['Y'], p['G'])


s = input()
l = len(s)
x = {'R': 0, 'B': 0, 'Y': 0, 'G': 0}
for i in range(4):
	a = 0
	col = ''
	for j in range(i, l, 4):
		if s[j] == '!':
			a += 1
		else:
			col = s[j]
	x[col] = a
print(*x.values())


s = input()
M_inv = {}
A = [0] * 4
for i in range(len(s)):
	if s[i] != '!':
		M_inv[s[i]] = i % 4
for i in range(len(s)):
	if s[i] == '!':
		A[i % 4] += 1
print(str(A[M_inv['R']]) + ' ' + str(A[M_inv['B']]) + ' ' + str(A[M_inv['Y']]) + ' ' + str(A[M_inv['G']]))


bulbs = input()
module = lambda x: x & 3
divide = lambda x: x >> 2
n = len(bulbs)
for ch in 'RBYG':
	postion = module(bulbs.find(ch))
	ans = divide(n + 3 - postion) - bulbs.count(ch)
	print('%d ' % ans)


import sys
import collections
from collections import Counter
import itertools
import math
import timeit

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	divisors = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				divisors.append(i)
			else:
				divisors.extend([i, n // i])
	return divisors

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def flin(d, x, default=-1):
	left = right = -1
	for i in range(len(d)):
		if d[i] == x:
			if left == -1:
				left = i
			right = i
	if left == -1:
		return (default, default)
	else:
		return (left, right)

def ceil(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)
s = input()
res = []
[res.append(len([j for j in range(s.find(i) % 4, len(s), 4) if s[j] == '!'])) for i in 'RBYG']
prr(res)


s = input()
n = len(s)
bulbs = [0] * n
pos = {}
for i in range(n):
	if s[i] == '!':
		bulbs[i % 4] += 1
	else:
		pos[s[i]] = i % 4
print(bulbs[pos['R']], bulbs[pos['B']], bulbs[pos['Y']], bulbs[pos['G']])


s = list(input())
d = {}
d['R'] = 0
d['B'] = 0
d['Y'] = 0
d['G'] = 0
ans = [''] * 4
for i in range(len(s)):
	if s[i] != '!':
		ans[i % 4] = s[i]
for i in range(len(s)):
	if s[i] == '!':
		d[ans[i % 4]] += 1
for i in d:
	print(d[i], end=' ')


s = input()
col_idx = {}
counts = [0, 0, 0, 0]
for (i, c) in enumerate(s):
	if c == '!':
		counts[i % 4] += 1
	else:
		col_idx[c] = i % 4
print('%d %d %d %d' % tuple((counts[col_idx[c]] for c in 'RBYG')))


def main():
	garland = input()
	order = {'R': -1, 'B': -1, 'Y': -1, 'G': -1}
	done = 4
	count = [0] * 4
	for i in range(0, len(garland)):
		if garland[i] != '!':
			if order[garland[i]] == -1:
				order[garland[i]] = i % 4
				done -= 1
				if done == 0:
					break
	for i in range(0, len(garland)):
		if garland[i] == '!':
			count[i % 4] += 1
	print(count[order['R']], end=' ')
	print(count[order['B']], end=' ')
	print(count[order['Y']], end=' ')
	print(count[order['G']], end=' ')
main()


def ri():
	return map(int, input().split())
s = input()
k = [0 for _ in range(4)]
color = ['' for _ in range(4)]
for i in range(len(s) // 4):
	b = s[i * 4:i * 4 + 4]
	for j in range(4):
		if b[j] == '!':
			k[j] += 1
		elif color[j] == '':
			color[j] = b[j]
if len(s) % 4:
	b = s[len(s) // 4 * 4:]
	for j in range(len(b)):
		if b[j] == '!':
			k[j] += 1
		elif color[j] == '':
			color[j] = b[j]
ans = [0 for _ in range(4)]
for j in range(4):
	if color[j] == 'R':
		ans[0] = k[j]
	if color[j] == 'B':
		ans[1] = k[j]
	if color[j] == 'Y':
		ans[2] = k[j]
	if color[j] == 'G':
		ans[3] = k[j]
print(' '.join(map(str, ans)))


def broken(s):
	for i in range(len(s)):
		if s[i] == 'B':
			b = i % 4
		elif s[i] == 'Y':
			y = i % 4
		elif s[i] == 'R':
			r = i % 4
		elif s[i] == 'G':
			g = i % 4
	(count1, count2, count3, count4) = (0, 0, 0, 0)
	for i in range(len(s)):
		if s[i] == '!':
			if i % 4 == b:
				count1 += 1
			elif i % 4 == y:
				count2 += 1
			elif i % 4 == r:
				count3 += 1
			elif i % 4 == g:
				count4 += 1
	return (count3, count1, count2, count4)
print(*broken(input()))


s = input()
cols = ['R', 'B', 'Y', 'G']
result = dict([(c, 0) for c in cols])
num_to_cols = dict()
for c in cols:
	num_to_cols[s.find(c) % 4] = c
for lnum in range(len(s)):
	if s[lnum] == '!':
		result[num_to_cols[lnum % 4]] += 1
print(result['R'], result['B'], result['Y'], result['G'])


import re
import sys
from bisect import bisect, bisect_left, insort, insort_left
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from itertools import accumulate, combinations, combinations_with_replacement, groupby, permutations, product
from math import acos, asin, atan, ceil, cos, degrees, factorial, hypot, log2, pi, radians, sin, sqrt, tan
from operator import itemgetter, mul
from string import ascii_lowercase, ascii_uppercase, digits

def inp():
	return int(input())

def inlist():
	return list(map(int, input().split()))

def instr():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())
S = instr()
n = len(S)
c = 0
K = [0] * 4
ir = S.index('R') % 4
ib = S.index('B') % 4
iy = S.index('Y') % 4
ig = S.index('G') % 4
for i in range(n):
	if S[i] == '!':
		if i % 4 == ir:
			K[0] += 1
		elif i % 4 == ib:
			K[1] += 1
		elif i % 4 == iy:
			K[2] += 1
		elif i % 4 == ig:
			K[3] += 1
print(*K)


Lights = input()
Pereg = [0] * 4
for i in range(0, len(Lights), 4):
	MasProm = Lights[i:i + 4]
	kol = MasProm.count('!')
	if not kol:
		pass
	else:
		Lena = len(MasProm)
		if Lena == 4:
			if 'R' not in MasProm:
				Pereg[0] += 1
			if 'B' not in MasProm:
				Pereg[1] += 1
			if 'Y' not in MasProm:
				Pereg[2] += 1
			if 'G' not in MasProm:
				Pereg[3] += 1
		else:
			Lamp = [''] * Lena
			for k in range(Lena):
				if MasProm[k] == '!':
					for j in range(k % 4, len(Lights), 4):
						if Lights[j] != '!':
							Lamp[k] = Lights[j]
			for k in range(Lena):
				if MasProm[k] == '!':
					if Lamp[k] == 'R':
						Pereg[0] += 1
					elif Lamp[k] == 'B':
						Pereg[1] += 1
					elif Lamp[k] == 'Y':
						Pereg[2] += 1
					elif Lamp[k] == 'G':
						Pereg[3] += 1
print(' '.join(map(str, Pereg)))


s = str(input())
n = len(s)
i = 0
cc = [0, 0, 0, 0]
colors = [0, 0, 0, 0]
ns = []
for i in range(n):
	if s[i] != '!':
		colors[i % 4] = s[i]
	else:
		ns.append(i)
for i in ns:
	if colors[i % 4] == 'R':
		cc[0] += 1
	elif colors[i % 4] == 'B':
		cc[1] += 1
	elif colors[i % 4] == 'Y':
		cc[2] += 1
	else:
		cc[3] += 1
for i in cc:
	print(i, end=' ')


s = input()
c = [s[i::4] for i in range(4)]
c = [j.count('!') for j in sorted(c, key=lambda x: [i for i in x if i != '!'][0])]
print(c[2], c[0], c[3], c[1])


light = input()
slices = []
n = len(light) % 4
for i in range(0, len(light) - n, 4):
	slices.append(light[i:i + 4])
slices.append(light[len(light) - n:len(light)] + '!' * (4 - n))
pattern = [''] * 4
for i in range(len(slices)):
	for j in range(len(slices[i])):
		if slices[i][j] != '!':
			pattern[j] = slices[i][j]
	if '' not in pattern:
		break
fault = {'R': 0, 'Y': 0, 'B': 0, 'G': 0}
for i in range(len(light)):
	if i % 4 == 0:
		if light[i] != pattern[0]:
			fault[pattern[0]] += 1
	elif (i - 1) % 4 == 0:
		if light[i] != pattern[1]:
			fault[pattern[1]] += 1
	if (i - 2) % 4 == 0:
		if light[i] != pattern[2]:
			fault[pattern[2]] += 1
	if (i - 3) % 4 == 0:
		if light[i] != pattern[3]:
			fault[pattern[3]] += 1
print(fault['R'], fault['B'], fault['Y'], fault['G'])


l = ['0', '0', '0', '0']
S = input()
l1 = [0, 0, 0, 0]
for i in range(len(S)):
	if S[i] == 'R':
		l[(i + 1) % 4 - 1] = 'R'
	if S[i] == 'B':
		l[(i + 1) % 4 - 1] = 'B'
	if S[i] == 'Y':
		l[(i + 1) % 4 - 1] = 'Y'
	if S[i] == 'G':
		l[(i + 1) % 4 - 1] = 'G'
for i in range(len(S)):
	if S[i] == '!':
		if l[(i + 1) % 4 - 1] == 'R':
			l1[0] = l1[0] + 1
		if l[(i + 1) % 4 - 1] == 'B':
			l1[1] = l1[1] + 1
		if l[(i + 1) % 4 - 1] == 'Y':
			l1[2] = l1[2] + 1
		if l[(i + 1) % 4 - 1] == 'G':
			l1[3] = l1[3] + 1
print(*l1)


from sys import stdin, stdout
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
mod = 1000000007
s = is1()
col = [''] * 4
c = 0
for i in range(len(s)):
	if s[i] != '!':
		if s[i] not in col:
			col[i % 4] = s[i]
			c += 1
	if c == 4:
		break
ans = [0, 0, 0, 0]
d = {'R': 0, 'B': 1, 'Y': 2, 'G': 3}
for i in range(len(s)):
	if s[i] == '!':
		ans[d[col[i % 4]]] += 1
print(*ans)


arr = input()
pos = [0, 1, 2, 3]
myd = {}
for c in pos:
	cnt = 0
	for l in range(c, len(arr), 4):
		if arr[l] != '!':
			k = arr[l]
		else:
			cnt = cnt + 1
	myd[k] = cnt
print('%d %d %d %d' % (myd['R'], myd['B'], myd['Y'], myd['G']))


g = list(input())
r = [0, 0, 0, 0]
c = {'R': 0, 'G': 0, 'B': 0, 'Y': 0}
l = len(g)
for i in range(0, l, 4):
	for j in range(4):
		if j + i < l:
			if g[i + j] == '!':
				r[j] += 1
			else:
				c[g[i + j]] = j
print(r[c['R']], r[c['B']], r[c['Y']], r[c['G']])


s = input()
c = {0: 0, 1: 0, 2: 0, 3: 0}
d = {'R': 0, 'B': 0, 'Y': 0, 'G': 0}
a = {'R': 0, 'B': 0, 'Y': 0, 'G': 0}
s1 = ''
for i in range(0, len(s)):
	if s[i] != '!':
		c[i % 4] = s[i]
		d[s[i]] += 1
		a[s[i]] += 1
for i in c.keys():
	if c[i] == 0:
		for j in d.keys():
			if d[j] == 0:
				c[i] = j
				break
n = len(s) % 4
for i in range(0, len(s)):
	if s[i] == '!':
		a[c[i % 4]] += 1
for i in d.keys():
	if d[i] != a[i]:
		s1 += str(a[i] - d[i])
	else:
		s1 += '0'
	if i != 'G':
		s1 += ' '
print(s1)


s = input()
b = s.find('B') % 4
r = s.find('R') % 4
g = s.find('G') % 4
y = s.find('Y') % 4
for x in [r, b, y, g]:
	cnt = 0
	for i in range(x, len(s), 4):
		if s[i] == '!':
			cnt += 1
	print(cnt, end=' ')


s1 = input()
s_len = len(s1)
ans = {'R': 0, 'B': 0, 'Y': 0, 'G': 0}
s = []
for i in range(s_len):
	s.append(s1[i])
for i in range(s_len):
	if s[i] == '!':
		num = 0
		j = i
		k = i
		if i <= 3:
			while s[j] == '!':
				j += 4
			ans[s[j]] += 1
		elif s_len - 1 - i <= 3:
			while s[k] == '!':
				k -= 4
			ans[s[k]] += 1
		else:
			while s[j] == '!' and s[k] == '!':
				if s_len - 1 - j <= 3:
					j -= 4
				if k <= 3:
					k += 4
				j += 4
				k -= 4
			if s[j] == '!':
				ans[s[k]] += 1
			else:
				ans[s[j]] += 1
result = ' '.join((str(value) for value in ans.values()))
print(result)


import sys
LI = lambda : list(map(int, sys.stdin.readline().split()))
MI = lambda : map(int, sys.stdin.readline().split())
SI = lambda : sys.stdin.readline().strip('\n')
II = lambda : int(sys.stdin.readline())
t = 'RGBY'
s = SI()
a = []
for i in range(4):
	for j in range(4):
		for k in range(4):
			for l in range(4):
				if len(set([i, j, k, l])) == 4:
					a.append(t[i] + t[j] + t[k] + t[l])
for t in a:
	ok = True
	for i in range(0, len(s), 4):
		for j in range(4):
			if i + j < len(s) and t[j] != s[i + j] and (s[i + j] != '!'):
				ok = False
	if ok:
		break
ans = {c: 0 for c in t}
for i in range(0, len(s), 4):
	for j in range(4):
		if i + j < len(s) and s[i + j] == '!':
			ans[t[j]] += 1
print(ans['R'], ans['B'], ans['Y'], ans['G'])


import sys
I = sys.stdin.readline
s = I().strip()
i = len(s) - len(s) % 4
R = i // 4 - s[0:i].count('R')
B = i // 4 - s[0:i].count('B')
Y = i // 4 - s[0:i].count('Y')
G = i // 4 - s[0:i].count('G')
flag = 1
if len(s) % 4:
	i = 0
	j = 4
	d = []
	sett = set()
	while j <= len(s):
		s1 = s[i:j]
		for k in range(len(s1)):
			if s1[k] != '!':
				if s1[k] not in sett:
					d.append((s1[k], k))
					sett.add(s1[k])
		i = j
		j += 4
		if j > len(s) and flag == 1:
			j = len(s)
			flag = 0
	d = sorted(d, key=lambda x: x[1])
	s2 = ''
	for i in d:
		s2 += i[0]
	x = s2[len(s) % 4:] + s[-(len(s) % 4):]
	R += 1 - x.count('R')
	B += 1 - x.count('B')
	Y += 1 - x.count('Y')
	G += 1 - x.count('G')
print(R, B, Y, G)


s = input()
ref = ['R', 'B', 'Y', 'G']
base = ['!', '!', '!', '!']
dead = [0, 0, 0, 0]
result = [0, 0, 0, 0]
i = 0
start = 0
while base[0] == '!':
	if s[start] != '!':
		base[0] = s[start]
	start += 4
start = 1
while base[1] == '!':
	if s[start] != '!':
		base[1] = s[start]
	start += 4
start = 2
while base[2] == '!':
	if s[start] != '!':
		base[2] = s[start]
	start += 4
start = 3
while base[3] == '!':
	if s[start] != '!':
		base[3] = s[start]
	start += 4
for i in range(len(s)):
	if (i + 1) % 4 == 0:
		if s[i] == '!':
			dead[3] += 1
	elif (i + 2) % 4 == 0:
		if s[i] == '!':
			dead[2] += 1
	elif (i + 3) % 4 == 0 and (i + 1) % 4 != 0:
		if s[i] == '!':
			dead[1] += 1
	elif s[i] == '!':
		dead[0] += 1
for i in range(4):
	for j in range(4):
		if ref[i] == base[j]:
			result[i] = str(dead[j])
			break
print(' '.join(result))


S = input()
r_i = S.find('R') % 4
b_i = S.find('B') % 4
y_i = S.find('Y') % 4
g_i = S.find('G') % 4
cnt = {r_i: 0, b_i: 0, y_i: 0, g_i: 0}
for (i, s) in enumerate(S):
	if s == '!':
		cnt[i % 4] += 1
print(cnt[r_i], cnt[b_i], cnt[y_i], cnt[g_i])


s = input()
l = [0] * 4
temp = [0] * 4
for i in range(len(s)):
	if s[i] != '!':
		a = s.index(s[i])
		if a < 4:
			l[a] = s[i]
		elif l[a % 4] == 0:
			l[a % 4] = s[i]
for j in range(len(s)):
	if s[j] == '!':
		temp[j % 4] += 1
r = l.index('R')
b = l.index('B')
y = l.index('Y')
g = l.index('G')
print(temp[r], end=' ')
print(temp[b], end=' ')
print(temp[y], end=' ')
print(temp[g])


s = input()
r = -1
b = -1
y = -1
g = -1
for i in range(0, len(s)):
	if s[i] == 'R':
		r = i % 4
	elif s[i] == 'B':
		b = i % 4
	elif s[i] == 'Y':
		y = i % 4
	elif s[i] == 'G':
		g = i % 4
	if r != -1 and b != -1 and (y != -1) and (g != -1):
		break
a = [0, 0, 0, 0]
for i in range(0, len(s)):
	if s[i] == '!':
		a[i % 4] += 1
print(a[r], a[b], a[y], a[g])


def main():
	str = input()
	seq = 'RBYG'
	pos = 0
	list = [0, 0, 0, 0]
	for i in range(len(seq)):
		pos = int(str.find(seq[i])) % 4
		for j in range(pos, len(str), 4):
			if str[j] == '!':
				list[i] += 1
	print(*list, sep=' ', end='\n')
main()


s = input()
n = len(s)
x1 = s.find('R') % 4
x2 = s.find('B') % 4
x3 = s.find('Y') % 4
x4 = s.find('G') % 4
(k1, k2, k3, k4) = (0, 0, 0, 0)
for i in range(x1, n, 4):
	if s[i] == '!':
		k1 += 1
for i in range(x2, n, 4):
	if s[i] == '!':
		k2 += 1
for i in range(x3, n, 4):
	if s[i] == '!':
		k3 += 1
for i in range(x4, n, 4):
	if s[i] == '!':
		k4 += 1
print(k1, k2, k3, k4)


g = input()
d = {}
u = []
for offset in range(4):
	count = 0
	char = '!'
	for i in range(offset, len(g), 4):
		if g[i] == '!':
			count = count + 1
		else:
			char = g[i]
	if char != '!':
		d[char] = count
	else:
		u.append(count)
if d['B'] == 0 and len(u) > 0:
	d['B'] = u.pop()
if d['R'] == 0 and len(u) > 0:
	d['R'] = u.pop()
if d['G'] == 0 and len(u) > 0:
	d['G'] = u.pop()
if d['Y'] == 0 and len(u) > 0:
	d['Y'] = u.pop()
print(d['R'], d['B'], d['Y'], d['G'])


s = input()
k = [0] * 4
p = [0] * 4
l = []
for i in range(0, len(s), 4):
	l.append(s[i:i + 4])
for i in l:
	if 0 not in k:
		break
	for j in range(len(i)):
		if i[j] != '!':
			k[j] = i[j]
for i in range(len(s)):
	if s[i] == '!':
		p[i % 4] += 1
print(p[k.index('R')], p[k.index('B')], p[k.index('Y')], p[k.index('G')])


s = input()
c = ['-', '-', '-', '-']
x = 0
i = 0
k = [0, 0, 0, 0]
k1 = [0, 0, 0, 0]
while '-' in c:
	if x > 3:
		x = 0
	if s[i] not in c and s[i] != '!':
		c[x] = s[i]
	x += 1
	i += 1
x = 0
for j in range(len(s)):
	if x > 3:
		x = 0
	if s[j] == '!':
		k[x] += 1
	x += 1
for h in range(4):
	if c[h] == 'R':
		k1[0] = k[h]
	elif c[h] == 'B':
		k1[1] = k[h]
	elif c[h] == 'Y':
		k1[2] = k[h]
	elif c[h] == 'G':
		k1[3] = k[h]
(z1, z2, z3, z4) = k1
print(z1, z2, z3, z4)


s = input()
a = dict()
k = 0
h = ''
for i in range(0, len(s), 4):
	if s[i] == '!':
		k += 1
	else:
		h = s[i]
a.update({h: k})
k = 0
for i in range(1, len(s), 4):
	if s[i] == '!':
		k += 1
	else:
		h = s[i]
a.update({h: k})
k = 0
for i in range(2, len(s), 4):
	if s[i] == '!':
		k += 1
	else:
		h = s[i]
a.update({h: k})
k = 0
for i in range(3, len(s), 4):
	if s[i] == '!':
		k += 1
	else:
		h = s[i]
a.update({h: k})
print(a['R'], a['B'], a['Y'], a['G'])


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
import random
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def main():
	s = S()
	d = {}
	r = [0] * 4
	for i in range(len(s)):
		t = s[i]
		if t == '!':
			r[i % 4] += 1
		else:
			d[t] = i % 4
	return ' '.join(map(lambda x: str(r[d[x]]), 'RBYG'))
print(main())


s = input()
l = ['?', '?', '?', '?']
d = {c: 0 for c in 'RGBY'}
for i in range(len(s)):
	if s[i] != '!':
		l[i % 4] = s[i]
for i in range(len(s)):
	if s[i] == '!':
		d[l[i % 4]] += 1
print(d['R'], d['B'], d['Y'], d['G'])


def f(s, i):
	a = len(s)
	while i + 4 < a:
		if s[i] == '!':
			s[i] = s[i + 4]
		else:
			s[i + 4] = s[i]
		i += 4
	while i - 4 >= 0:
		if s[i] == '!':
			s[i] = s[i - 4]
		else:
			s[i - 4] = s[i]
		i -= 4
	return s
s = [i for i in input()]
d = s.copy()
for i in range(len(s)):
	if s[i] in 'RYGB':
		s = f(s, i)
e = {'R': 0, 'B': 0, 'Y': 0, 'G': 0}
for i in range(len(s)):
	if d[i] == '!':
		e[s[i]] += 1
r = []
for i in e:
	r.append(e[i])
print(*r)


s = input()
(pos, i, ans) = ({}, 0, [0, 0, 0, 0])
while True:
	if i == len(s):
		break
	k = i % 4
	pos[s[i]] = k
	if s[i] == '!':
		ans[k] += 1
	i += 1
print(ans[pos['R']], ans[pos['B']], ans[pos['Y']], ans[pos['G']])


from collections import defaultdict
pos = {}
broken = defaultdict(int)
s = input().strip()
for i in range(len(s)):
	if s[i] != '!':
		pos[i % 4] = s[i]
for i in range(len(s)):
	if s[i] == '!':
		broken[pos[i % 4]] += 1
print(broken['R'], broken['B'], broken['Y'], broken['G'])


s = input()
r = s.index('R') % 4
b = s.index('B') % 4
y = s.index('Y') % 4
g = s.index('G') % 4
rc = s[r::4].count('!')
bc = s[b::4].count('!')
yc = s[y::4].count('!')
gc = s[g::4].count('!')
print(rc, bc, yc, gc)


s = input()
rs = [0, 0, 0, 0]
rs_map = {'R': 0, 'G': 0, 'B': 0, 'Y': 0}
for (index, c) in enumerate(s):
	if c == '!':
		rs[index % 4] += 1
	else:
		rs_map[c] = index % 4
print(' '.join(map(str, [rs[rs_map['R']], rs[rs_map['B']], rs[rs_map['Y']], rs[rs_map['G']]])))


import sys
s = input()
n = len(s)
ans = [0] * 4
a = s.index('R') % 4
for i in range(a, n, 4):
	if s[i] != 'R':
		ans[0] += 1
a = s.index('B') % 4
for i in range(a, n, 4):
	if s[i] != 'B':
		ans[1] += 1
a = s.index('Y') % 4
for i in range(a, n, 4):
	if s[i] != 'Y':
		ans[2] += 1
a = s.index('G') % 4
for i in range(a, n, 4):
	if s[i] != 'G':
		ans[3] += 1
print(*ans)


s = input()
(q, w, e, t) = (0, 0, 0, 0)
s = s + 'aaaaaaaaaa'
r = s.find('R') % 4
b = s.find('B') % 4
y = s.find('Y') % 4
g = s.find('G') % 4
while r <= len(s) - 5:
	if s[r] == '!':
		q = q + 1
	r = r + 4
while b <= len(s) - 5:
	if s[b] == '!':
		w = w + 1
	b = b + 4
while y <= len(s) - 5:
	if s[y] == '!':
		e = e + 1
	y = y + 4
while g <= len(s) - 5:
	if s[g] == '!':
		t = t + 1
	g = g + 4
print(q, w, e, t)


s = input()
seq = ['-' for i in range(4)]
have_not = {'R': 0, 'B': 0, 'Y': 0, 'G': 0}
for i in range(len(s)):
	if s[i] != '!':
		seq[i % 4] = s[i]
for i in range(len(s)):
	if s[i] == '!':
		have_not[seq[i % 4]] += 1
print(have_not['R'], have_not['B'], have_not['Y'], have_not['G'])


a = input()
b = [[0 for i in range(2)] for i in range(4)]
k = 0
for i in a:
	if i == '!':
		b[k % 4][1] += 1
	elif i == 'R':
		b[k % 4][0] = 0
	elif i == 'B':
		b[k % 4][0] = 1
	elif i == 'Y':
		b[k % 4][0] = 2
	elif i == 'G':
		b[k % 4][0] = 3
	k += 1
for i in sorted(b):
	print(i[1], end=' ')


s = input()
(r, b, y, g) = (0, 0, 0, 0)
j = 0
aux = ['!'] * 4
for i in range(4, len(s) + 1, 4):
	for k in range(j, i):
		if s[k] != '!' and aux[k % 4] == '!':
			aux[k % 4] = s[k]
	if s[j:i].find('R') == -1:
		r += 1
	if s[j:i].find('B') == -1:
		b += 1
	if s[j:i].find('Y') == -1:
		y += 1
	if s[j:i].find('G') == -1:
		g += 1
	j = i
for i in range(j, len(s)):
	if s[i] == '!':
		if aux[i % 4] == 'R':
			r += 1
		if aux[i % 4] == 'B':
			b += 1
		if aux[i % 4] == 'Y':
			y += 1
		if aux[i % 4] == 'G':
			g += 1
print(r, b, y, g)


n = input()
n = list(n)
(r, b, y, g) = (0, 0, 0, 0)
for i in range(len(n)):
	if n[i] == '!':
		for j in range(len(n)):
			if j % 4 == i % 4 and n[j] != '!':
				if n[j] == 'R':
					r += 1
				elif n[j] == 'B':
					b += 1
				elif n[j] == 'Y':
					y += 1
				elif n[j] == 'G':
					g += 1
				n[i] = n[j]
				break
print(r, b, y, g)


import sys
from itertools import cycle
from itertools import permutations
S = input()
cnt = {'R': 0, 'B': 0, 'Y': 0, 'G': 0}
rbyg = ('R', 'B', 'Y', 'G')
for col4 in permutations(rbyg):
	cyc = cycle(col4)
	kouho = ''
	for i in range(len(S)):
		kouho += next(cyc)
	for (c1, c2) in zip(S, kouho):
		if c1 != '!' and c1 != c2:
			break
	else:
		for (c1, c2) in zip(S, kouho):
			if c1 == '!':
				cnt[c2] += 1
		print(cnt['R'], cnt['B'], cnt['Y'], cnt['G'])
		sys.exit(0)


s = input()
k = ''
o = 0
l = [0] * 4

def lll(j):
	global l
	if j == 'R':
		l[0] += 1
	elif j == 'B':
		l[1] += 1
	elif j == 'Y':
		l[2] += 1
	else:
		l[3] += 1
	return l
for rr in range(4):
	for i in range(len(s)):
		if s[i] != '!' and i % 4 == o:
			k = k + s[i]
			o += 1
		if len(k) == 4:
			break
	if len(k) == 4:
		break
ll = (len(s) // 4 + 1) * 4 * k
for i in range(len(s)):
	if s[i] != ll[i]:
		lll(ll[i])
for i in range(4):
	l[i] = str(l[i])
print(' '.join(l))


n = list(input())
f = {'R': 0, 'G': 0, 'B': 0, 'Y': 0}
t = [0] * 4
for k in range(len(n)):
	if n[k] != '!':
		f[n[k]] = (k + 1) % 4
	if 0 not in f.values():
		break
for i in range(len(n)):
	if n[i] == '!':
		u = (i + 1) % 4
		if f['R'] == u:
			t[0] += 1
		elif f['B'] == u:
			t[1] += 1
		elif f['Y'] == u:
			t[2] += 1
		else:
			t[3] += 1
print(*t)


def main():
	s = list(input())
	ans = []
	for c in 'RBYG':
		x = s.index(c)
		x %= 4
		cn = 0
		while x < len(s):
			if s[x] == '!':
				cn += 1
			x += 4
		ans.append(cn)
	print(*ans)
main()


s = list(input())
on = [s[i] for i in range(0, len(s), 4)]
tw = [s[i] for i in range(1, len(s), 4)]
th = [s[i] for i in range(2, len(s), 4)]
fo = [s[i] for i in range(3, len(s), 4)]
if 'R' in on:
	kr = on.count('!')
if 'R' in tw:
	kr = tw.count('!')
if 'R' in th:
	kr = th.count('!')
if 'R' in fo:
	kr = fo.count('!')
if 'B' in on:
	kb = on.count('!')
if 'B' in tw:
	kb = tw.count('!')
if 'B' in th:
	kb = th.count('!')
if 'B' in fo:
	kb = fo.count('!')
if 'Y' in on:
	ky = on.count('!')
if 'Y' in tw:
	ky = tw.count('!')
if 'Y' in th:
	ky = th.count('!')
if 'Y' in fo:
	ky = fo.count('!')
if 'G' in on:
	kg = on.count('!')
if 'G' in tw:
	kg = tw.count('!')
if 'G' in th:
	kg = th.count('!')
if 'G' in fo:
	kg = fo.count('!')
print(kr, kb, ky, kg)


INDEX_TO_COLOR = dict()
counter = {'R': 0, 'B': 0, 'Y': 0, 'G': 0}
s = input()
for i in range(len(s)):
	if s[i] != '!':
		INDEX_TO_COLOR[i % 4] = s[i]
for i in range(len(s)):
	if s[i] == '!':
		counter[INDEX_TO_COLOR[i % 4]] += 1
print(counter['R'], counter['B'], counter['Y'], counter['G'])