Polycarp has interviewed Oleg and has written the interview down without punctuation marks and spaces to save time. Thus, the interview is now a string s consisting of n lowercase English letters.

There is a filler word ogo in Oleg's speech. All words that can be obtained from ogo by adding go several times to the end of it are also considered to be fillers. For example, the words ogo, ogogo, ogogogo are fillers, but the words go, og, ogog, ogogog and oggo are not fillers.

The fillers have maximal size, for example, for ogogoo speech we can't consider ogo a filler and goo as a normal phrase. We should consider ogogo as a filler here.

To print the interview, Polycarp has to replace each of the fillers with three asterisks. Note that a filler word is replaced with exactly three asterisks regardless of its length.

Polycarp has dealt with this problem in no time. Can you do the same? The clock is ticking!


-----Input-----

The first line contains a positive integer n (1 ≤ n ≤ 100) — the length of the interview.

The second line contains the string s of length n, consisting of lowercase English letters.


-----Output-----

Print the interview text after the replacement of each of the fillers with "***". It is allowed for the substring "***" to have several consecutive occurences.


-----Examples-----
Input
7
aogogob

Output
a***b

Input
13
ogogmgogogogo

Output
***gmg***

Input
9
ogoogoogo

Output
*********



-----Note-----

The first sample contains one filler word ogogo, so the interview for printing is "a***b".

The second sample contains two fillers ogo and ogogogo. Thus, the interview is transformed to "***gmg***".

Source: codeforces | Difficulty: EASY
Tags: String algorithms

Implementation


Solutions:
num = int(input())
s = input()
s = s.replace('ogo', '***')
while '*go' in s:
	s = s.replace('*go', '*')
while '***g***' in s:
	s = s.replace('***g***', '***')
print(s)


(n, s) = (int(input()) // 2, input())
while n:
	s = s.replace('og' * n + 'o', '***')
	n -= 1
print(s)


n = int(input())
s = input()
while s.count('ogo') > 0:
	i = 0
	j = 0
	while s[i:i + 3] != 'ogo':
		i += 1
	if s[i:i + 3] == 'ogo':
		j = i + 3
		while j + 2 <= len(s) and s[j:j + 2] == 'go':
			j += 2
		s = s[:i] + '***' + s[j:]
print(s)


input()
s = input()
for i in range(50, 0, -1):
	bad = 'o' + 'go' * i
	s = s.replace(bad, '***')
print(s)


from sys import *
n = int(input())
a = input()
s = 0
i = 0
while i <= n - 1:
	if s == 0:
		if a[i:i + 3] == 'ogo':
			s = 1
			print('***', end='')
			i += 3
		else:
			print(a[i], end='')
			i += 1
	elif a[i:i + 2] == 'go':
		i += 2
	else:
		s = 0


import sys
fin = sys.stdin
fout = sys.stdout
n = int(fin.readline())
s = fin.readline().strip()
res = ''
i = 0
while i < len(s):
	if s[i:i + 3] == 'ogo':
		last = len(s)
		for j in range(i + 3, len(s), 2):
			last = j
			if s[j:j + 2] != 'go':
				res += '***'
				i = j - 1
				break
		else:
			res += '***'
			i = last + 2
	else:
		res += s[i]
	i += 1
fout.write(res)


n = int(input())
k = str(input())
i = k.find('ogo')
while i != -1:
	j = i
	while j <= n - 2:
		if k[j + 1:j + 3] == 'go':
			j += 2
		else:
			break
	k = k.replace(k[i:j + 1], '***', 1)
	i = k.find('ogo')
print(k)


input()
s = input()
while 'ogogo' in s:
	s = s.replace('ogogo', 'ogo')
print(s.replace('ogo', '***'))


_ = input()
s = input()
i = 0
out = ''

def howMany(n):
	global s
	going = True
	out = 0
	while n < len(s) and going:
		if n + 1 < len(s) and s[n] == 'g' and (s[n + 1] == 'o'):
			out += 1
			n += 2
		else:
			n += 1
			going = False
	return out
while i < len(s):
	if i + 2 < len(s) and s[i] == 'o' and (s[i + 1] == 'g') and (s[i + 2] == 'o'):
		i += 3 + howMany(i + 3) * 2
		out = out + '***'
	else:
		out = out + s[i]
		i += 1
print(out)


import math
import itertools
import collections

def getdict(n):
	d = {}
	if type(n) is list:
		for i in n:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
	else:
		for i in range(n):
			t = ii()
			if t in d:
				d[t] += 1
			else:
				d[t] = 1
	return d

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 sumc(t):
	s = 0
	while t > 0:
		s += t % 10
		t //= 10
	return s
n = ii()
s = input()
for i in range(48, -1, -1):
	s = s.replace('ogo' + 'go' * i, '***')
print(s)


n = int(input())
s = input()
par = 'o' + 'go' * (len(s) // 2)
while len(par) > 2:
	i = 0
	while par in s:
		s = s.replace(par, '***')
	par = par[:-2]
	i += 1
print(s)


n = int(input())
s = input()
first = 'o' + 'go' * n
while first != 'o':
	s = s.replace(first, '***')
	n -= 1
	first = 'o' + 'go' * n
print(s)


number = int(input())
stringBeutiful = input()
rangeoff = range(number, 0, -1)
for i in rangeoff:
	w = 'o' + 'go' * i
	stringBeutiful = stringBeutiful.replace(w, '***')
print(stringBeutiful)


pat = __import__('re').compile('o(go)+')
input()
line = input()
while True:
	s = pat.search(line)
	if not s:
		break
	s = s.span(0)
	line = line[:s[0]] + '***' + line[s[1]:]
print(line)


ans = ['ogo', 'ogogo', 'ogogogo', 'ogogogogo', 'ogogogogogo', 'ogogogogogogo', 'ogogogogogogogo', 'ogogogogogogogogo', 'ogogogogogogogogogo', 'ogogogogogogogogogogo', 'ogogogogogogogogogogogo', 'ogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo']
n = int(input())
s = input()
for i in range(len(ans) - 1, -1, -1):
	s = s.replace(ans[i], '***')
print(s)


import re
input()
print(re.sub('ogo(go)*', '***', input()))


n = int(input())
s = input()
a = s.find('ogo')
while a != -1:
	k = a + 2
	while k + 2 < len(s) and s[k + 1:k + 3] == 'go':
		k += 2
	s = s[:a] + '***' + s[k + 1:]
	a = s.find('ogo')
print(s)


n = int(input())
a = input() + 'aaa'
ans = ''
i = 0
ogo = False
while i < n:
	if a[i:i + 3] == 'ogo':
		ans += '***'
		i += 3
		ogo = True
	elif a[i:i + 2] == 'go' and ogo:
		i += 2
	else:
		ogo = False
		ans += a[i]
		i += 1
print(ans)


n = int(input())
s = input()
for i in range(n):
	if 'ogo' in s:
		s = s.replace('ogo', '***')
j = s.split('*go')
k = '*'.join(j)
l = k.split('**g*')
print(''.join(l))


n = int(input())
s = input()
for golen in range(97, -1, -1):
	s = s.replace('ogo' + 'go' * golen, '***')
print(s)


n = int(input())
s = input()
ans = ''
l = ['o', 'g']
i = 0
while i < n:
	curr = s[i]
	if s[i] == 'o':
		t = i
		i += 1
		while i < n and s[i] == l[(i - t) % 2]:
			curr += s[i]
			i += 1
		if i - t >= 3:
			if curr[-1] == 'o':
				ans += '***'
			else:
				ans += '***'
				ans += 'g'
		else:
			ans += curr
	else:
		ans += s[i]
		i += 1
print(ans)


import re
Input = lambda : map(int, input().split())
n = int(input())
s = input()
t = re.sub('o(go)+', '***', s)
print(t)


def cens(line):
	result = ''
	go = False
	i = 0
	while i < len(line):
		if line[i:i + 3] == 'ogo':
			go = True
			result += '***'
			i += 2
		elif line[i:i + 2] == 'go' and go:
			i += 1
		else:
			go = False
			result += line[i]
		i += 1
	return result
input()
line = input()
print(cens(line))


n = int(input())
s = input().replace('ogo', '***')
for i in range(50):
	s = s.replace('**g**', '*')
	s = s.replace('*go', '*')
print(s)


n = int(input())
s = ''
s += input()
for i in range(int(n / 2), 0, -1):
	a = 'o' + 'go' * i
	while s.find(a) >= 0:
		s = s.replace(a, '***')
print(s)


n = int(input())
s = input()
i = 0
S = ''
while i < n:
	if s[i:i + 3] == 'ogo':
		i += 3
		S += '***'
		while i < n:
			if s[i:i + 2] == 'go':
				i += 2
			else:
				break
	else:
		S += s[i]
		i += 1
print(S)


n = int(input())
string = str(input())
while string.find('ogo') > -1:
	f = string.find('ogo')
	end = f + 3
	end2 = end + 2
	while string[end:end2] == 'go':
		end += 2
		end2 = end + 2
	string = string[:f] + '***' + string[end:]
print(string)


n = int(input())
s = input()
ans = ''
i = 0
while i <= n - 2:
	if i <= n - 3 and s[i:i + 3] == 'ogo':
		j = i + 3
		while j <= n - 2 and s[j:j + 2] == 'go':
			j += 2
		ans += '***'
		i = j
	else:
		ans += s[i]
		i += 1
if i != n:
	for i in range(i, n):
		ans += s[i]
print(ans)


import re
input()
print(re.sub('o(go)+', '***', input()))


(n, s) = (int(input()), input())
(s, ans) = (s + 'ii', [])
i = 0
while i < n:
	if s[i] == 'o' and s[i + 1] == 'g' and (s[i + 2] == 'o'):
		i += 3
		while i < n and s[i] == 'g' and (s[i + 1] == 'o'):
			i += 2
		ans.append('***')
	else:
		ans.append(s[i])
		i += 1
print(''.join(ans))


n = int(input())
s = input().rstrip()
i = 0
while i < n:
	if s[i] != 'o':
		print(s[i], end='')
	else:
		j = i + 1
		while j < n - 1 and s[j] == 'g' and (s[j + 1] == 'o'):
			j += 2
		if j != i + 1:
			print('***', end='')
		else:
			print(s[i], end='')
		i = j - 1
	i += 1


L = int(input())
S = input()
cond = 0
go_counter = 0
ans = []
for i in range(L):
	if cond == 0:
		if S[i] == 'o':
			cond = 1
			continue
		ans.append(S[i])
		continue
	if cond == 1:
		if S[i] == 'g':
			cond = 2
			continue
		ans.append('o')
		if S[i] != 'o':
			ans.append(S[i])
			cond = 0
		continue
	if cond == 2:
		if S[i] == 'o':
			cond = 3
			continue
		ans.append('o')
		ans.append('g')
		ans.append(S[i])
		cond = 0
		continue
	if cond == 3:
		if S[i] == 'g':
			cond = 4
			continue
		ans.append('*')
		ans.append('*')
		ans.append('*')
		if S[i] == 'o':
			cond = 1
		else:
			cond = 0
			ans.append(S[i])
		continue
	if cond == 4:
		if S[i] == 'o':
			cond = 5
			continue
		ans.append('*')
		ans.append('*')
		ans.append('*')
		ans.append('g')
		ans.append(S[i])
		cond = 0
	if cond == 5:
		if S[i] == 'g':
			cond = 4
			continue
		ans.append('*')
		ans.append('*')
		ans.append('*')
		if S[i] == 'o':
			cond = 1
		else:
			ans.append(S[i])
			cond = 0
if cond == 1:
	ans.append('o')
if cond == 2:
	ans.append('o')
	ans.append('g')
if cond == 3 or cond == 5:
	ans.append('*')
	ans.append('*')
	ans.append('*')
if cond == 4:
	ans.append('*')
	ans.append('*')
	ans.append('*')
	ans.append('g')
for i in ans:
	print(i, end='')


length = int(input())
interview = input()
substring = 'ogo' + (length - 3) * 'go'
while len(substring) > 2:
	if substring in interview:
		interview = interview.replace(substring, '***')
	substring = substring[:-2]
print(interview)


import re
lenth = input()
result = re.sub('o(go)*go', '***', input())
print(result)


l = int(input())
s = input()
l += 2
s += '  '
ret = ''
i = 0
while i < l - 2:
	if s[i] == 'o' and s[i + 1] == 'g' and (s[i + 2] == 'o'):
		j = i + 3
		while j < l - 1:
			if s[j] == 'g' and s[j + 1] == 'o':
				j += 2
			else:
				break
		ret += '***'
		i = j
	else:
		ret += s[i]
		i += 1
print(ret)


n = int(input())
s = str(input())
while '***go' in s or 'ogo' in s:
	k = s.find('ogo')
	if k != -1:
		s = s[:k + 3].replace('ogo', '***') + s[k + 3:]
	while '***go' in s:
		s = s.replace('***go', '***')
print(s)


import re
n = int(input())
s = input()
s = re.sub('ogo(go)*', '***', s)
print(s)


n = int(input())
s = input()
i = 0
answer = ''
while i < n:
	if s[i:i + 3] == 'ogo':
		j = i + 3
		while j < n:
			if s[j:j + 2] == 'go':
				j += 2
			else:
				break
		i = j
		answer += '***'
	else:
		answer += s[i]
		i += 1
print(answer)


import re
n = int(input())
s = input()
q = 'ogogo'
k = 50
while n != 0:
	com = re.compile(q)
	result1 = re.sub(com, 'ogo', s)
	s = result1
	n -= 1
result1 = re.sub('ogo', '***', result1)
print(result1)


n = int(input())
s = input()
strings = ['ogo']
for i in range(50):
	strings += [strings[-1] + 'go']
for i in range(len(strings) - 1, -1, -1):
	if len(strings[i]) <= len(s):
		s = s.replace(strings[i], '***')
print(s)


n = int(input())
s = input() + 'aa'
i = 0
res = ''
while i < n:
	if s[i] != 'o':
		res += s[i]
	elif s[i + 1:i + 3] == 'go':
		res += '***'
		i += 3
		while s[i:i + 2] == 'go':
			i += 2
		i -= 1
	else:
		res += 'o'
	i += 1
print(res)


def is_filler(s):
	if len(s) < 3:
		return False
	if s != 'ogo' + (len(s) - 3) // 2 * 'go':
		return False
	return True
n = int(input())
s = input()
ln = n - 1
for _ in range(n):
	for i in range(n):
		if i + ln + 1 > n:
			ln -= 1
			break
		if is_filler(s[i:i + ln + 1]):
			s = s[:i] + '***' + s[i + ln + 1:]
print(s)


n = input()
s = input()
while ('ogo' in s) | ('***go' in s):
	num = s.find('ogo')
	if num != -1:
		s = s[:num + 3].replace('ogo', '***') + s[num + 3:]
	while '***go' in s:
		s = s.replace('***go', '***')
print(s)


t = int(input())
t = input()
i = 0
while i < len(t) - 2:
	if t[i] == 'o' and t[i + 1] == 'g' and (t[i + 2] == 'o'):
		j = i + 3
		while j < len(t) - 1:
			if t[j] + t[j + 1] == 'go':
				pass
			else:
				break
			j = j + 2
		t = t[:i] + '***' + t[j:]
	i = i + 1
print(t)


n = int(input())
s = input()
l = list(s)
i = 0
while i < n:
	j = i
	if s[i] == 'o':
		flag = 0
		while s[i + 1:i + 3] == 'go':
			flag += 1
			i = i + 2
		if flag >= 1:
			for x in range(j, j + 3):
				l[x] = '*'
			for x in range(j + 3, i + 1):
				l[x] = '+'
	i += 1
ans = ''
for i in l:
	if i != '+':
		ans += i
print(ans)


n = int(input())
s = input()
while n > 0:
	s = s.replace('ogo' + (n - 1) * 'go', '***')
	n -= 1
print(s)


import re
_ = input()
string = input()
print(re.sub('ogo(go)*', '***', string))


import re
n = int(input())
print(re.sub('o(go)+', '***', input()))


import re
n = input()
cad = input()
print(re.sub('o(go)+', '***', cad))


t = int(input())
s = input()
i = 0
cout = []
while i < len(s):
	if s[i] != 'o':
		cout.append(s[i])
	else:
		j = i + 1
		while j < len(s) - 1 and s[j] + s[j + 1] == 'go':
			j += 2
		if j == i + 1:
			cout.append(s[i])
		else:
			cout.append('***')
		i = j - 1
	i += 1
print(''.join(cout))


n = int(input())
word = input()
word = word.lower()
for i in range(n, 0, -1):
	bad = 'ogo' + (i - 1) * 'go'
	word = word.replace(bad, '***')
	bad = ''
print(word)


n = int(input())
st = input()
while n > 0:
	st = st.replace('ogo' + (n - 1) * 'go', '***')
	n -= 1
print(st)


n = int(input())
s = str(input())
for i in range(n):
	if s[i:i + 3] == 'ogo':
		j = i + 3
		s = s[0:i] + '***' + s[i + 3:]
		for k in range(j, j + 1, 2):
			while s[k:k + 2] == 'go':
				s = s[0:k] + s[k + 2:]
print(s)


l = int(input())
w = input()
wc = w
s = None
n = 0
o = True
l = 0
for (i, c) in enumerate(w + '.'):
	if o and c == 'o':
		o = False
		if s is None:
			s = i
		n += 1
	elif not o and c == 'g':
		o = True
		n += 1
	else:
		if n < 3:
			s = None
			n = 0
			o = True
			if c == 'o':
				s = i
				n += 1
				o = False
			continue
		e = i
		if n % 2 == 0:
			e -= 1
			n -= 1
		wc = wc[:s - l] + '***' + w[e:]
		l += n - 3
		s = None
		n = 0
		o = True
		if c == 'o':
			s = i
			n += 1
			o = False
print(wc)


n = int(input())
s = input()

def findEnd(s, i):
	k = i + 2
	ans = i + 2
	while k + 2 < len(s):
		if s[k + 1:k + 3] == 'go':
			ans = k + 2
		else:
			break
		k += 2
	return ans

def findOgogos(s):
	return (s.find('ogo'), findEnd(s, s.find('ogo')))
while 'ogo' in s:
	s = s[:s.find('ogo')] + '***' + s[findEnd(s, s.find('ogo')) + 1:]
print(s)


n = int(input())
a = list(input())
word = False
last = ''
ans = []
i = 0
while i < n:
	if not word and i <= n - 3 and (a[i] == 'o') and (a[i + 1] == 'g') and (a[i + 2] == 'o'):
		word = True
		last = a[i + 2]
		i += 2
	elif word and last == 'o' and (a[i] == 'g') and (i < n - 1) and (a[i + 1] == 'o'):
		last = a[i]
	elif word and last == 'g' and (a[i] == 'o'):
		last = a[i]
	elif word:
		word = False
		ans.append('***')
		if i <= n - 3 and a[i] == 'o' and (a[i + 1] == 'g') and (a[i + 2] == 'o'):
			word = True
			last = a[i + 2]
			i += 2
		else:
			ans.append(a[i])
	else:
		ans.append(a[i])
	i += 1
if word:
	ans.append('***')
print(''.join(map(str, ans)))


n = int(input())
line = str(input())
rest = str()
pos = 0
while True:
	fact = 3
	if pos + fact <= n and line[pos:pos + fact] == 'ogo':
		pos += fact
		fact = 2
		while True:
			if pos + fact <= n and line[pos:pos + fact] == 'go':
				pos += fact
			else:
				rest += '***'
				break
	else:
		rest += line[pos]
		pos += 1
	if pos == n:
		break
print(rest)


n = int(input())
line = input()
while len(line) > 0:
	f = line.find('ogo')
	if f != -1:
		print(line[:f], end='')
		print('***', end='')
		line = line[f + 3:]
		while line.find('go') == 0:
			line = line[2:]
	else:
		print(line, end='')
		break


from re import sub

def main():
	input()
	print(sub('o(go)+', '***', input()))
main()


n = int(input())
s = input()
l = []
t = 'o'
for _ in range(n // 2):
	t += 'go'
	l.append(t)
for x in l[::-1]:
	s = s.replace(x, '***')
print(s)


n = input()
del n
string = input()
string_out = ''
i = 0
end = len(string)
while i != end:
	if string[i:i + 3] == 'ogo':
		buf = '***'
		i += 3
		while True:
			if string[i:i + 2] == 'go':
				i += 2
			elif string[i:i + 3] == 'ogo':
				i += 3
				buf += '***'
			else:
				break
	else:
		buf = string[i]
		i += 1
	string_out += buf
	buf = ''
print(string_out)


n = input()
s = input()
while 'ogo' in s:
	n = 0
	r = 'ogo'
	i = s.index(r)
	while s[i + 3 + 2 * n:i + 5 + 2 * n] == 'go':
		r += 'go'
		n += 1
	s = s.replace(r, '***', 1)
print(s)


s = input()
s = input()
sogo = 'og' * 50
i = 0
while i < len(s):
	i = s.find('ogo')
	if i == -1:
		break
	k = i + 3
	while k < len(s) + 1 and s[i:k] == sogo[0:k - i]:
		k = k + 2
	if k >= len(s) or s[i:k] != sogo[0:k - i]:
		srep = s[i:k - 2]
	else:
		srep = s[i:k]
	s = s.replace(srep, '***', 1)
	i = k
print(s)


n = int(input())
mystr = list(input())
mystr.append('qq')
mystr.append('qq')
mystr.append('qq')
mystr.append('qq')
result = []
i = 0
while i <= len(mystr) - 1:
	if i < len(mystr) - 2:
		if mystr[i] == mystr[i + 2] == 'o' and mystr[i + 1] == 'g':
			j = i + 3
			while mystr[j] == 'g' and mystr[j + 1] == 'o':
				j += 2
			i = j
			result.append('***')
		else:
			result.append(mystr[i])
			i += 1
	else:
		result.append(mystr[i])
		i += 1
while result[-1] == 'qq':
	result.pop()
print(''.join(result))


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_int_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_int = lambda : int(sys.stdin.readline())
n = get_int()
s = list(get_string())
i = 0
while i < n - 2:
	if s[i] == 'o' and s[i + 1] == 'g' and (s[i + 2] == 'o'):
		(s[i], s[i + 1], s[i + 2]) = ('*', '*', '*')
		i = i + 2
		j = i + 1
		while j < n - 1:
			if s[j] == 'g' and s[j + 1] == 'o':
				(s[j], s[j + 1]) = ('', '')
				j += 2
			else:
				break
		i = max(i + 1, j - 1)
	else:
		i += 1
print(''.join(s))


import re

def norm(s):
	result = re.sub('(ogo)(go)*', '***', s)
	return result
i = input()
s = input()
print(norm(s))


n = int(input())
s = input().strip()
while True:
	a = -1
	for i in range(len(s) - 2):
		if s[i:i + 3] == 'ogo':
			a = i + 2
			for j in range(i + 3, len(s) - 1, 2):
				if s[j:j + 2] != 'go':
					break
				a = j + 1
			s = s[:i] + '***' + s[a + 1:]
			break
	if a == -1:
		break
print(s)


n = int(input())
l = list(input())
for i in range(1, n - 1):
	if l[i] == 'g' and l[i + 1] == 'o' and (l[i - 1] == 'o'):
		l[i] = '*'
		l[i - 1] = '*'
		l[i + 1] = '*'
	elif l[i] == 'g' and l[i + 1] == 'o' and (l[i - 1] == '*' or l[i - 1] == ''):
		l[i] = ''
		l[i + 1] = ''
print(''.join(l))


a = int(input())
b = str(input())
c = b.replace('o', '1')
c = c.replace('g', '2')
for i in range(a):
	c = c.replace('121', '3')
	c = c.replace('321', '3')
	c = c.replace('3', '***')
	c = c.replace('2', 'g')
	c = c.replace('***g***', '***')
c = c.replace('1', 'o')
print(c)


n = int(input())
s = str(input())
while s.find('ogo') != -1:
	e = 0
	while s[s.find('ogo') + 3 + e * 2:s.find('ogo') + 3 + 2 * (e + 1)] == 'go':
		e += 1
	s = s.replace(s[s.find('ogo'):s.find('ogo') + 3 + e * 2], '***', 1)
print(s)


n = int(input())
text = input()
parazit = ''
for i in range(n):
	if text[i:i + 3] == 'ogo':
		parazit = 'o'
		while text[i + 1:i + 3] == 'go':
			parazit += text[i + 1:i + 3]
			i += 2
		text = text.replace(parazit, '***', 1)
print(text)


import re
n = input()
s = input()
print(re.sub('o(go)+', '***', s))


n = int(input())
st = input()
for i in range(n):
	if i < n - 2 and st[i:i + 3] == 'ogo':
		j = i + 3
		while j < n and st[j:j + 2] == 'go':
			j += 2
		st = st.replace(st[i:j], '***', 1)
		i = j
print(st)


n = int(input())
s = input()
ans = 'ogo'
a = []
while len(ans) <= 100:
	a.append(ans)
	ans += 'go'
i = n
j = len(a) - 1
while True:
	if a[j] in s:
		q = s.index(a[j])
		s = s[:q] + '***' + s[q + len(a[j]):]
	else:
		j -= 1
	if j == -1:
		break
print(s)


n = int(input())
s = input()
ans = ''
cur = 0
while cur < n:
	if cur + 2 < n and s[cur:cur + 3] == 'ogo':
		ln = cur + 3
		while ln + 1 < n and s[ln:ln + 2] == 'go':
			ln += 2
		ans += '***'
		cur = ln
	else:
		ans += s[cur]
		cur += 1
print(ans)


n = int(input())
s = list(input())
l = []
i = 0
while i < n:
	if s[i] == 'o' and s[i + 1:i + 3] == ['g', 'o']:
		l.append('***')
		while i < n - 1 and s[i + 1:i + 3] == ['g', 'o']:
			i += 2
		i += 1
	else:
		l.append(s[i])
		i += 1
print(''.join(l))


n = int(input())
s = input()
x = 0
flag = 0
while x < len(s) - 2:
	if s[x:x + 3] == 'ogo':
		right = x
		left = x + 3
		flag = 0
		for i in range(x + 3, len(s) - 1, 2):
			if s[i:i + 2] == 'go' and flag == 0:
				left += 2
			else:
				flag = 1
		s = s[:right] + '***' + s[left:]
	x += 1
print(s)


n = int(input())
s = input()
ans = ''
i = 0
while i < n:
	if i + 2 < n and s[i:i + 3] == 'ogo':
		i += 3
		while i + 1 < n and s[i:i + 2] == 'go':
			i += 2
		ans += '***'
	else:
		ans += s[i]
		i += 1
print(ans)


n = int(input())
s = input()
ptr = 'ogo' + 'go' * 50
while len(ptr) > 1:
	s = s.replace(ptr, '***')
	ptr = ptr[:-2]
print(s)


input()
s = input()
m = [0 for i in range(len(s))]
i = 0
while i < len(s):
	if i + 2 < len(s) and s[i:i + 3] == 'ogo':
		i += 3
		while i < len(s) - 1 and s[i:i + 2] == 'go':
			i += 2
		print('***', end='')
		i -= 1
	else:
		print(s[i], end='')
	i += 1


import re
r = '(ogo(go)*)'
input()
s = input()
s = re.sub(r, '***', s)
print(s)


n = int(input())
s = input()
while s.find('ogo') != -1:
	start = s.find('ogo')
	finish = start + 3
	while finish + 1 < len(s) and s[finish] == 'g' and (s[finish + 1] == 'o'):
		finish += 2
	s = s[:start] + '***' + s[finish:]
print(s)


n = input()
st = input()
s = 'ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo'
while st.find('ogo') >= 0:
	i = 3
	k = 0
	while st.find(s[0:i]) >= 0:
		k = st.find(s[0:i])
		i = i + 2
	if k >= 0:
		st = st[0:k] + '***' + st[k + i - 2:]
print(st)


import re
interview = int(input())
speech = input()
speech = re.sub('ogo(go)*', '***', speech)
print(speech)


b = int(input())
a = input()
s = ''
for i in range(len(a)):
	s += a[i]
	q = s.find('ogo')
	if q != -1:
		s = s[:q] + '***'
	q = s.find('*go')
	if q != -1:
		s = s[:q + 1] + ''
print(s)


n = int(input())
s = input()
while 'ogo' in s:
	if s[s.index('ogo'):s.index('ogo') + 5] == 'ogogo':
		s = s[:s.index('ogo')] + s[s.index('ogo') + 2:]
	else:
		s = s[:s.index('ogo')] + '***' + s[s.index('ogo') + 3:]
print(s)


n = int(input())
s = input()
for i in range(100, 0, -1):
	s = s.replace('o' + 'go' * i, '***')
print(s)


import re
n = int(input())
s = input()
s = s.lower()
while 'ogo' in s:
	s = re.sub('o(go)+', '***', s)
print(s)


n = int(input())
s = input()
a = 0
b = 0
for i in range(len(s)):
	if a == 0:
		if s[i:i + 3] == 'ogo':
			a = 2
			for j in range((len(s) - i) // 2):
				if s[i + 3 + j * 2:i + 5 + j * 2] == 'go':
					a = 2 + (j + 1) * 2
				else:
					break
			print('***', end='')
		else:
			print(s[i], end='')
	else:
		a = a - 1


letters = ['o', 'g']
n = int(input())
s = input()
a = 0
while a < n:
	b = 0
	while a < n and s[a] == letters[b % 2]:
		a += 1
		b += 1
	if b >= 3:
		if b % 2 == 0:
			a -= 1
			b -= 1
		s = s[:a - b] + '***' + ' ' * (b - 3) + s[a:]
	elif b == 0:
		a += 1
s = s.replace(' ', '')
print(s)


s = int(input())
b = input()
b = b.replace('ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', '***')
b = b.replace('ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', '***')
b = b.replace('ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', '***')
b = b.replace('ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', '***')
b = b.replace('ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', '***')
b = b.replace('ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', '***')
b = b.replace('ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', '***')
b = b.replace('ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', '***')
b = b.replace('ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', '***')
b = b.replace('ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', '***')
b = b.replace('ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', '***')
b = b.replace('ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', '***')
b = b.replace('ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', '***')
b = b.replace('ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', '***')
b = b.replace('ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', '***')
b = b.replace('ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', '***')
b = b.replace('ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', '***')
b = b.replace('ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', '***')
b = b.replace('ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', '***')
b = b.replace('ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', '***')
b = b.replace('ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', '***')
b = b.replace('ogogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', '***')
b = b.replace('ogogogogogogogogogogogogogogogogogogogogogogogogogogogogo', '***')
b = b.replace('ogogogogogogogogogogogogogogogogogogogogogogogogogogogo', '***')
b = b.replace('ogogogogogogogogogogogogogogogogogogogogogogogogogogo', '***')
b = b.replace('ogogogogogogogogogogogogogogogogogogogogogogogogogo', '***')
b = b.replace('ogogogogogogogogogogogogogogogogogogogogogogogogo', '***')
b = b.replace('ogogogogogogogogogogogogogogogogogogogogogogogo', '***')
b = b.replace('ogogogogogogogogogogogogogogogogogogogogogogo', '***')
b = b.replace('ogogogogogogogogogogogogogogogogogogogogogo', '***')
b = b.replace('ogogogogogogogogogogogogogogogogogogogogo', '***')
b = b.replace('ogogogogogogogogogogogogogogogogogogogo', '***')
b = b.replace('ogogogogogogogogogogogogogogogogogogo', '***')
b = b.replace('ogogogogogogogogogogogogogogogogogo', '***')
b = b.replace('ogogogogogogogogogogogogogogogogo', '***')
b = b.replace('ogogogogogogogogogogogogogogogo', '***')
b = b.replace('ogogogogogogogogogogogogogogo', '***')
b = b.replace('ogogogogogogogogogogogogogo', '***')
b = b.replace('ogogogogogogogogogogogogo', '***')
b = b.replace('ogogogogogogogogogogogo', '***')
b = b.replace('ogogogogogogogogogogo', '***')
b = b.replace('ogogogogogogogogogo', '***')
b = b.replace('ogogogogogogogogo', '***')
b = b.replace('ogogogogogogogo', '***')
b = b.replace('ogogogogogogo', '***')
b = b.replace('ogogogogogo', '***')
b = b.replace('ogogogogo', '***')
b = b.replace('ogogogo', '***')
b = b.replace('ogogo', '***')
b = b.replace('ogo', '***')
print(b)


l = int(input())
str = input()
ans = ''
i = 0
flag = 0
while i < l:
	if str[i:i + 3] == 'ogo':
		flag = 1
		ans += '***'
		i += 3
	elif str[i:i + 2] == 'go' and flag:
		i += 2
		continue
	else:
		flag = 0
		ans += str[i]
		i += 1
print(ans)


import re
n = int(input())
cad = input()
newcad = re.sub('o(go)+', '***', cad)
print(newcad)


n = int(input())
arr = list(input())
for i in range(n - 2):
	if arr[i:i + 3] == ['o', 'g', 'o']:
		q = i + 3
		for j in range(i + 3, n - 1, 2):
			if arr[j] + arr[j + 1] == 'go':
				q += 2
			else:
				break
		arr[i:q] = ['*'] * (q - i)
		arr[q - 1] = '*1'
for el in arr:
	if el == '*':
		pass
	elif el == '*1':
		print('***', end='')
	else:
		print(el, end='')


n = int(input())
s = input()
i = 0
j = ''
while i + 2 < n:
	if s[i] + s[i + 1] + s[i + 2] == 'ogo':
		i += 1
		while i + 1 < n and s[i] + s[i + 1] == 'go':
			i += 2
		j += '***'
	else:
		j += s[i]
		i += 1
while i < n:
	j += s[i]
	i += 1
print(j)


l = input()
s = input()
for i in range(len(s) // 2, -1, -1):
	s = s.replace('ogo' + 'go' * i, '***')
print(s)


n = int(input())
s = str(input())
i = 0
while i < len(s) - 2:
	if s[i] == 'o' and s[i + 1] == 'g' and (s[i + 2] == 'o'):
		k = i
		temp = i + 3
		while temp < len(s) - 1 and s[temp] == 'g' and (s[temp + 1] == 'o'):
			temp = temp + 2
		s = s[:k] + '***' + s[temp:]
	i = i + 1
print(s)


n = int(input())
s = str(input())
k = n - 3
if k > 0:
	t = k // 2
	for i in range(t, -1, -1):
		s = s.replace('ogo' + 'go' * i, '***')
else:
	s = s.replace('ogo', '***')
print(s)


n = int(input())
s = input()
p = 'ogo'
while len(p) < len(s):
	p += 'go'
while len(p) > 1:
	s = s.replace(p, '***')
	p = p[:-2]
print(s)


x = int(input())
y = input()
i = len(y)
while i > 1:
	i = i - 1
	if 'og' * i + 'o' in y:
		y = y.replace('og' * i + 'o', '***')
print(y)


input()
s = input()
l = []
st = 'ogo'
for i in range(0, 100):
	l.append(st)
	st += 'go'
l.reverse()
for e in l:
	s = s.replace(e, '*')
s = s.replace('*', '***')
print(s)


n1 = int(input())
s = list(input())

def zfunc(s1, n):
	i1 = 0
	z = []
	for i1 in range(n):
		z.append(0)
	z[0] = 0
	x = 0
	length = 0
	for i1 in range(1, n):
		if i1 <= x + length:
			z[i1] = min(z[i1 - x], x + length - i1)
		while z[i1] + i1 < n and s1[z[i1]] == s1[i1 + z[i1]]:
			z[i1] += 1
		if i1 + z[i1] > x + length:
			x = i1
			length = z[i1]
	return z
s.insert(0, '#')
s.insert(0, 'o')
s.insert(0, 'g')
s.insert(0, 'o')
t = zfunc(s, len(s))
i = 4
sc = 0
j = 0
i2 = 0
s2 = ''
mas = []
while i < n1 + 4:
	if t[i] == 3:
		sc = 3
		i2 = i
		while t[i + 2] == 3:
			i += 2
			sc += 2
		for j in range(3):
			del s[i2]
		s.insert(i2, '*')
		s.insert(i2, '*')
		s.insert(i2, '*')
		for j in range(i2 + 3, sc + i2):
			s[j] = '&'
	i += 1
for i in range(4, len(s)):
	if s[i] != '&':
		s2 += s[i]
print(s2)


n = int(input())
s = input()
res = ''
ogo = False
i = 0
while i < n:
	if i < n - 2 and s[i:i + 3] == 'ogo':
		ogo = True
		i += 3
		res += '***'
	elif i < n - 1 and s[i:i + 2] == 'go' and ogo:
		i += 2
	else:
		ogo = False
		res += s[i]
		i += 1
print(res)


input()
s = input()
s1 = 'ogo' + 'go' * 110
while len(s1) > 1:
	s = s.replace(s1, '***')
	s1 = s1.replace('go', '', 1)
print(s)


n = int(input())
s = input()
f1 = 0
while True:
	f = s.find('ogo')
	if f > -1:
		f1 = f + 3
		while True:
			if f1 + 2 <= n:
				if s[f1:f1 + 2] == 'go':
					f1 += 2
				else:
					break
			else:
				break
		s = s[:f] + '***' + s[f1:]
	else:
		break
print(s)


l = int(input().strip())
s = input().strip()
r = ''
i = 0
while i < l:
	if s[i:i + 3] == 'ogo':
		k = i + 3
		while k < l:
			if s[k:k + 2] != 'go':
				break
			k += 2
		r += '***'
		i = k
	else:
		r += s[i]
		i += 1
print(r)


n = int(input())
s = input()
i = 0
otv = ''
while i < n:
	if s[i] != 'o':
		otv = otv + s[i]
	else:
		if s[i + 1:i + 3] == 'go':
			otv = otv + '***'
		else:
			otv = otv + 'o'
		while s[i + 1:i + 3] == 'go':
			i = i + 2
	i = i + 1
print(otv)


from math import ceil
input()
x = input()
for i in range(100, 0, -1):
	ss = 'o' + 'go' * i
	while ss in x:
		x = x.replace(ss, '***')
print(x)


n = int(input())
s = input().strip()
rez = ''
i = 0
while i < len(s):
	if s[i:i + 3] == 'ogo':
		j = i + 3
		while s[j:j + 2] == 'go':
			j += 2
		i = j
		rez += '***'
	else:
		rez += s[i]
		i += 1
print(rez)


n = int(input())
a = input()
(f1, f2) = (0, 0)
st = True
cur = 0
ans = ''
while cur < n:
	if cur >= n - 2 or a[cur] + a[cur + 1] + a[cur + 2] != 'ogo':
		ans += a[cur]
		cur += 1
		continue
	ans += '***'
	cur += 1
	while cur + 1 < n and a[cur] == 'g' and (a[cur + 1] == 'o'):
		cur += 2
print(ans)


n = int(input())
s = input()
i = 0
parasits = ['o' + 'go' * i for i in range(49, 0, -1)]
for string in parasits:
	if string in s:
		s = s.replace(string, '***')
print(s)


n = int(input())
s = input()
(i, a) = (0, [])
while i < n:
	if s[i:i + 3] == 'ogo':
		a.append(i)
		i += 3
	elif s[i:i + 2] == 'go' and s[i - 1] == 'o' and (i != 0):
		i += 2
	else:
		a.append(s[i])
		i += 1
r = ''
for i in a:
	if type(i) == int:
		r += '***'
	else:
		r += i
print(r)


input()
S = input()
i = 0
k = 0
while i < len(S):
	if S[i] == 'o':
		if k % 2 == 0:
			k += 1
		elif k > 2:
			S = S[:i - k] + '***' + S[i:]
			i -= k
			k = 1
		else:
			k = 1
	elif S[i] == 'g':
		if k % 2 == 1:
			k += 1
		elif k > 2:
			i -= 1
			k -= 1
			S = S[:i - k] + '***' + S[i:]
			i -= k
			k = 0
		else:
			k = 0
	else:
		if k > 2:
			if k % 2 == 0:
				k -= 1
				i -= 1
			S = S[:i - k] + '***' + S[i:]
			i -= k
		k = 0
	i += 1
if k > 2:
	if k % 2 == 0:
		i -= 1
		k -= 1
	S = S[:i - k] + '***' + S[i:]
print(S)


n = int(input())
s = input()
i = n
t = 'o' + 'go' * i
while i > 0:
	while s.count(t) >= 1:
		x = s.find(t)
		l = len(t)
		s = s[0:x] + '***' + s[x + l:]
	i -= 1
	t = 'o' + 'go' * i
print(s)


l = int(input())
arr = list(input())
for g in range((l - 3) // 2, -1, -1):
	n = ['o', 'g', 'o'] + ['g', 'o'] * g
	inx = []
	i = 0
	while i <= len(arr) - len(n):
		if arr[i:i + len(n)] == n:
			inx.append([i, i + len(n)])
			i += len(n)
		else:
			i += 1
	m = len(n) - 3
	for i in range(len(inx)):
		arr = arr[:inx[i][0] - m * i] + ['*', '*', '*'] + arr[inx[i][1] - m * i:]
print(*arr, sep='')


n = int(input())
a = input()
c = []
for i in range(0, n):
	c.append([a[i]])
for i in range(0, n - 2):
	if a[i] == 'o' and a[i + 1] == 'g' and (a[i + 2] == 'o'):
		c[i].append('*')
		c[i + 1].append('*')
		c[i + 2].append('*')
	else:
		c[i].append(a[i])
		c[i + 1].append(a[i + 1])
		c[i + 2].append(a[i + 2])
k = []
for i in range(0, n):
	k.append([])
for i in range(0, n - 1):
	if '*' in c[i]:
		if c[i][0] == 'o' and c[i + 1][0] == 'g' or (c[i][0] == 'g' and c[i + 1][0] == 'o'):
			k[i].append('*')
	else:
		k[i].append(c[i][0])
if '*' not in c[n - 1]:
	k[n - 1].append(c[n - 1][0])
p = []
h = 0
for i in range(0, n):
	if '*' in k[i]:
		h += 1
		if h <= 3:
			p.append('*')
	elif k[i] == []:
		h += 1
		if h <= 3:
			p.append('*')
		h = 0
	else:
		h = 0
		p.append(k[i][0])
for i in range(0, len(p)):
	print(p[i], end='')


n = int(input())
a = list(input())
p = ''
ans = ''
i = 0
while i < n:
	if len(p) == 0 and i <= n - 3 and (a[i] == 'o') and (a[i + 1] == 'g') and (a[i + 2] == 'o'):
		p = 'ogo'
		i += 3
		while i < n - 1:
			if a[i] == 'g' and a[i + 1] == 'o':
				p += 'go'
				i += 2
			else:
				ans += '***'
				p = ''
				break
		else:
			ans += '***'
	else:
		ans += a[i]
		i += 1
print(ans)


import sys
import math
import bisect
import itertools
import random
import re

def main():
	n = int(input())
	s = input()
	s = re.sub('ogo(go)*', '***', s)
	print(s)
main()


n = int(input())
a = input()
i = 0
b = ''
while i + 2 < n:
	if a[i] + a[i + 1] + a[i + 2] == 'ogo':
		i += 1
		while i + 1 < n and a[i] + a[i + 1] == 'go':
			i += 2
		b += '***'
	else:
		b += a[i]
		i += 1
while i < n:
	b += a[i]
	i += 1
print(b)


n = int(input())
s = input()
i = 0
while i < n:
	if s[i:i + 3] == 'ogo':
		while s[i:i + 3] == 'ogo':
			i += 2
		print('***', end='')
	else:
		print(s[i], end='')
	i += 1


n = int(input())
word = input()
sub = 'ogo'
if sub not in word:
	print(word)
else:
	for i in range(n - 3, -1, -1):
		if 'ogo' + 'go' * i in word:
			word = word.replace('ogo' + 'go' * i, '***')
	print(word)


n = int(input())
s = input()
(x, i) = (0, 0)
while i < n:
	if i < n - 2 and s[i] == 'o' and (s[i + 1] == 'g') and (s[i + 2] == 'o'):
		print('***', end='')
		x = 1
		i += 3
	elif i < n - 1 and s[i] == 'g' and (s[i + 1] == 'o') and x:
		i += 2
	else:
		x = 0
		print(s[i], end='')
		i += 1


input()
s = input() + 's '
f = s.find('ogo')
while f != -1:
	c = f + 3
	while s[c] + s[c + 1] == 'go':
		c += 2
	s = s[:f] + '***' + s[c:]
	f = s.find('ogo')
print(s[:len(s) - 2])


from math import ceil
n = int(input())
x = input()
p = ['ogo'] + ['ogo' + 'go' * i for i in range(1, 50)]
j = ceil((n - 3) / 2)
if n < 3:
	print(x)
else:
	while j >= 0:
		if p[j] in x:
			x = x.replace(p[j], '***')
		else:
			j = j - 1
	print(x)


from sys import stdin
max_val = int(10000000000000.0)
min_val = int(-10000000000000.0)

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

def read_ints():
	return [int(x) for x in stdin.readline().split()]

def read_str():
	return input()

def read_strs():
	return [x for x in stdin.readline().split()]
import re
l = int(input())
s = input()
ans = re.sub('ogo(go)*', '***', s)
print(ans)


input()
s = input()
i = 0
last = 0
new = ''
while i < len(s) - 2:
	if s[i] == 'o' and s[i + 1] == 'g' and (s[i + 2] == 'o'):
		start = i
		i += 2
		end = i
		while i < len(s) - 2:
			if s[i] == 'o' and s[i + 1] == 'g' and (s[i + 2] == 'o'):
				i += 2
				end = i
			else:
				break
		new += s[last:start] + '***'
		last = end + 1
	i += 1
new += s[last:]
print(new)


import re
num = input()
x = input()
y = re.sub('o(go)+', '***', x)
print(y)


input()
s = input()
s += '-' * 20
nn = 0
while nn == 0:
	try:
		idd = s.index('ogo')
		d = idd + 3
		for i in range(idd + 3, len(s), 2):
			if s[i] + s[i + 1] == 'go':
				d += 2
			else:
				break
	except:
		break
	s = s[0:idd] + '***' + s[d:len(s)]
print(s[0:len(s) - 20])


n = int(input())
s = input()
cut = 'ogo' + 'go' * 49
while True:
	if cut != 'ogo':
		s = s.replace(cut, '***')
		cut = str(cut[0:-2])
	else:
		s = s.replace(cut, '***')
		break
print(s)


n = int(input())
a = list(str(input()))
i = j = 0
while j < n:
	i = j
	if ''.join(a[i:i + 3]) == 'ogo':
		i = i + 3
		while ''.join(a[i:i + 2]) == 'go':
			i += 2
		j = i
		print('***', end='')
	else:
		print(a[i], end='')
		j += 1


n = int(input())
s = input()
found = s.find('ogo')
while found != -1:
	next_letter = 'g'
	last_good = found + 3
	for i in s[found + 3:]:
		if i == next_letter:
			if next_letter == 'g':
				next_letter = 'o'
			else:
				next_letter = 'g'
				last_good += 2
		else:
			break
	s = s[:found] + '***' + s[last_good:]
	found = s.find('ogo')
print(s)


n = int(input())
s = input()
(a, b) = (True, True)
if 'ogo' not in s:
	print(s)
else:
	while b == True:
		a = True
		k = s.index('ogo')
		s = s[0:k] + '***' + s[k + 3:]
		i = k + 3
		while i < len(s) and a == True:
			if s[i:i + 2] == 'go':
				s = s[0:i] + s[i + 2:]
			else:
				a = False
		if 'ogo' not in s:
			b = False
	print(s)


(n, s) = (int(input()), input())
result_array = []
left = 0
while left <= n - 3:
	if s[left:left + 3] == 'ogo':
		left += 3
		if left >= n:
			result_array.append('***')
			break
		while left + 1 < n and s[left:left + 2] == 'go':
			left += 2
		result_array.append('***')
	else:
		result_array.append(s[left])
		left += 1
while left < n:
	result_array.append(s[left])
	left += 1
print(''.join(result_array))


def main(n, s):
	ret = ''
	i = 0
	while i < n:
		if i + 2 < n and s[i] == 'o' and (s[i + 1] == 'g') and (s[i + 2] == 'o'):
			ret += '***'
			j = i + 1
			while j + 1 < n:
				if s[j] == 'g' and s[j + 1] == 'o':
					s[j] = '*'
					s[j + 1] = '*'
					j += 2
				else:
					break
			i = j - 1
		else:
			ret += s[i]
		i += 1
	return ''.join(ret)
print(main(int(input()), list(input())))


import re
n = int(input())
a = input()
print(re.sub('ogo(go)*', '***', a))


dai = int(input())
s = input()
chay = list(range(3, dai + 1, 2))
chay.reverse()
for i in chay:
	tmp = 'o'
	tmp += 'go' * int((i - 1) / 2)
	s = s.replace(tmp, '***')
print(s)


input()
s = input()
for i in range(100, -1, -1):
	s = s.replace('ogo' + 'go' * i, '***')
print(s)


n = int(input())
s = input()
i = 3
g = 0
string = ' '
for j in range(n):
	if g == 0:
		if string[-1] == '*' and 'go' == s[j:i - 1]:
			g = 1
		elif 'ogo' == s[j:i]:
			string += '***'
			g = 2
		else:
			string += s[j]
		i += 1
	else:
		g -= 1
		i += 1
print(string[1:])


a = int(input())
b = [i for i in input()]
i = 0
while i < a:
	if i + 2 < a and b[i] == 'o' and (b[i + 1] == 'g') and (b[i + 2] == 'o'):
		k = 0
		while i + 2 < a and b[i + 1] == 'g' and (b[i + 2] == 'o'):
			i += 2
			if k == 0:
				print('***', end='')
			k = 1
	else:
		print(b[i], end='')
	i += 1


n = int(input())
s = input()
while s.find('ogo') != -1:
	i = s.find('ogo')
	s = s[:i] + '***' + s[i + 3:]
	i += 3
	while i < n - 1 and s[i] == 'g' and (s[i + 1] == 'o'):
		s = s[:i] + '##' + s[i + 2:]
		i += 2
for i in s:
	if i == '#':
		continue
	print(i, end='')


n = int(input())
s = input()
ogos = ['ogo']
ogo = 'ogogo'
while len(ogo) <= n:
	ogos.append(ogo)
	ogo += 'go'
for i in range(1, len(ogos) + 1):
	ogo = ogos[-i]
	a = s.find(ogo)
	while a != -1:
		s = s[:a] + '*' * 3 + s[a + len(ogo):]
		a = s.find(ogo)
print(s)


n = int(input())
str = input()
i = -1
ans = []
while i < len(str) - 1:
	i += 1
	flag = 0
	if i < len(str) - 2:
		if str[i] == 'o' and str[i + 1] == 'g' and (str[i + 2] == 'o'):
			while i < len(str) - 2 and str[i + 1] == 'g' and (str[i + 2] == 'o'):
				i += 2
			ans.append('***')
			flag = 1
	if flag == 0:
		ans.append(str[i])
for i in range(len(ans)):
	print(ans[i], end='')


import re as r
n = input()
new = input()
print(r.sub('ogo(go)*', '***', new))


n = int(input())
string = input()
word = 'ogo' + 'go' * 56
for i in range(57):
	string = string.replace(word, '***')
	word = word[:-2]
print(string)


n = int(input())
s = list(input()) + ['0', '0', '0', '0']
i = 0
while i < len(s) - 3:
	if s[i] + s[i + 1] + s[i + 2] == 'ogo':
		(s[i + 2], s[i + 1], s[i]) = ('*', '*', '*')
		i += 3
		while i < len(s) - 2:
			if s[i] + s[i + 1] == 'go':
				del s[i + 1], s[i]
			else:
				break
	else:
		i += 1
print(''.join(map(str, s[:-4])))


n = int(input())
s = input()
while s.find('ogo') != -1:
	s = s.replace('ogo', '***', 1)
	while s.find('***go') != -1:
		s = s.replace('***go', '***', 1)
print(s)


x = int(input())
s = input()
a = 'ogo'
b = 'go'
count = 0
for i in range(len(s)):
	while count <= x:
		s = s.replace(a + b, a)
		count += 1
s = s.replace('ogo', '***')
print(s)


p = int(input())
s = input()
p = s.find('ogo')
i = 0
while p > -1:
	i = p + 3
	while s[i:i + 2] == 'go':
		i = i + 2
	s = s[0:p] + '***' + s[i:len(s)]
	p = s.find('ogo')
print(s)


input()
s = input()
ogo = s.find('ogo')
while ogo != -1:
	s = s[0:ogo] + '***' + s[ogo + 3:]
	while s[ogo + 3:ogo + 5] == 'go':
		s = s[0:ogo + 3] + s[ogo + 5:]
	ogo = s.find('ogo')
print(s)


a = int(input())
s = input()
k = ''
if len(s) < 3:
	print(s)
else:
	q = 'ogo'
	d = 'go'
	i = 0
	q1 = 0
	while i < a - 3:
		if s[i:i + 3] == q:
			j = i + 3
			while s[j:j + 2] == d:
				j += 2
			k += '***'
			q1 = j
			i = j
			continue
		else:
			k += s[i]
			i += 1
	if q1 > a - 3:
		k += s[q1:a]
	elif s[a - 3:a] == q:
		k += '***'
	else:
		k += s[a - 3:a]
	print(k)


def solve():
	n = int(input())
	s = list(input())
	x = 0
	result = ''
	while x <= len(s) - 3:
		if s[x:x + 3] == ['o', 'g', 'o']:
			result += '*' * 3
			x += 3
			while s[x:x + 2] == ['g', 'o']:
				x += 2
		else:
			result += s[x]
			x += 1
	for i in range(x, len(s)):
		result += s[i]
	print(result)
solve()


n = int(input())
s = input()
let = s.find('ogo')
if let == -1:
	print(s)
else:
	while s.find('ogo') != -1:
		let = s.find('ogo')
		letgo = let + 3
		while True:
			if len(s) <= letgo + 1:
				break
			elif (s[letgo] == 'g') & (s[letgo + 1] == 'o'):
				letgo += 2
			else:
				break
		s = s[:let] + '***' + s[letgo:]
	print(s)


import re
print(re.sub('o(go)+', '***', [*open(0)][1]))


n = int(input())
s = input()
l = list(s)
i = s.find('ogo')
while i > -1:
	l[i] = '*'
	l[i + 1] = '*'
	l[i + 2] = '*'
	k = i + 3
	t = s.find('go', k)
	while t > 0 and t == k:
		l[k] = '#'
		l[k + 1] = '#'
		k += 2
		t = s.find('go', k)
	i = s.find('ogo', k)
print(''.join([b for b in l if b != '#']))


n = int(input())
a = input()
b = []
i = 0
while i < n:
	if a[i] == 'o':
		if i + 2 < n:
			if a[i + 1] == 'g' and a[i + 2] == 'o':
				j = i + 3
				b.append('***')
				while j + 1 < n:
					k = a[j] + a[j + 1]
					if k == 'go':
						j += 2
					else:
						break
				i = j
			else:
				b.append(a[i])
				i += 1
		else:
			b.append(a[i])
			i += 1
	else:
		b.append(a[i])
		i += 1
print(''.join(b))


n = int(input())
s = input()
for i in range(n // 2, -1, -1):
	s = s.replace('ogo' + i * 'go', '***')
print(s)


a = ['ogo']
for i in range(48):
	s = a[-1] + 'go'
	a.append(s)
ans = []
n = int(input())
s = input()
i = 0
while i < n:
	flag = 0
	for j in reversed(a):
		if s[i:].startswith(j):
			ans.append('***')
			flag = 1
			break
	if flag == 0:
		ans.append(s[i])
		i += 1
	else:
		i += len(j)
print(''.join(ans))


clen = int(input())
sentence = input()
news = ''
cchar = ''
pchar = ''
tmp = ''
for i in range(clen):
	cchar = sentence[i]
	if pchar == '':
		if cchar == 'o':
			tmp = cchar
		else:
			news = cchar
	elif tmp == '':
		if cchar == 'o':
			tmp = cchar
		else:
			news = news + sentence[i]
	elif len(tmp) < 3:
		if cchar == 'o':
			if cchar != tmp[-1]:
				tmp = tmp + cchar
			else:
				news = news + tmp
				tmp = 'o'
		elif cchar == 'g':
			if cchar != tmp[-1]:
				tmp = tmp + cchar
			else:
				news = news + tmp + cchar
				tmp = ''
		else:
			news = news + tmp + cchar
			tmp = ''
	elif (len(tmp) - 1) % 2 == 0:
		if cchar == 'g':
			tmp = tmp + cchar
		elif cchar == 'o':
			news = news + '***'
			tmp = 'o'
		else:
			news = news + '***' + cchar
			tmp = ''
	elif cchar == 'o':
		tmp = tmp + cchar
	else:
		news = news + '***' + 'g' + cchar
		tmp = ''
	pchar = sentence[i]
if len(tmp) < 3:
	news = news + tmp
elif tmp[-1] == 'o':
	news = news + '***'
else:
	news = news + '***' + 'g'
print(news)


input()
interview = input()
for (i, n) in enumerate(interview):
	if interview[i:i + 3] == 'ogo':
		end = i + 3
		while interview[end:end + 2] == 'go':
			end += 2
		interview = interview[:i] + '***' + interview[end:]
print(interview)


def compute_prefix_function(p):
	s = [0] * len(p)
	border = 0
	for i in range(1, len(p)):
		while border > 0 and p[i] != p[border]:
			border = s[border - 1]
		if p[i] == p[border]:
			border += 1
		else:
			border = 0
		s[i] = border
	return s

def kmp(p, t, sep='$'):
	S = '{}{}{}'.format(p, sep, t)
	s = compute_prefix_function(S)
	result = []
	for i in range(len(p), len(S)):
		if s[i] == len(p):
			result.append(i - 2 * len(p))
	return result
length = int(input())
string = input()
matches = kmp('ogo', string)
if not matches:
	print(string)
else:
	bounds = []
	i = 0
	while i < len(matches):
		left = matches[i]
		right = matches[i] + 2
		while True:
			if i >= len(matches):
				break
			elif i + 1 < len(matches) and left <= matches[i + 1] <= right:
				right += 2
				i += 1
			else:
				bounds.append((left, right))
				break
		i += 1
	i = 0
	j = 0
	output = []
	while i < len(string) or j <= len(bounds):
		if j < len(bounds):
			(left, right) = bounds[j]
			start = i
			while i != left:
				i += 1
			output.append(string[start:left])
			output.append('***')
			j += 1
			i = right
		else:
			output.append(string[i:])
			break
		i += 1
	print(''.join(output))


n = int(input())
s = input()
i = 0
ans = ''
while i < n:
	if i <= n - 3 and s[i:i + 3] == 'ogo':
		j = i + 3
		while j < n - 1:
			if s[j] == 'g' and s[j + 1] == 'o':
				j += 2
			else:
				break
		ans += '***'
		i = j
	else:
		ans += s[i]
		i += 1
print(ans)


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')
n = int(input())
s = input()
ans = ''
ind = 0
while ind < n:
	if ind + 2 < n and s[ind:ind + 3] == 'ogo':
		ans += '***'
		ind += 3
		while ind + 1 < n and s[ind:ind + 2] == 'go':
			ind += 2
	else:
		ans += s[ind]
		ind += 1
print(ans)


from sys import stdin
import re
regex = re.compile('ogo(go)*')
lines = stdin.readlines()
outString = re.sub(regex, '***', lines[1])
print(outString)


a = int(input())
b = input()
ans = ''
s = 0
while b.find('ogo', s) != -1:
	co = b.find('ogo', s)
	ans += b[s:co]
	ko = 3
	while b.find('go', co + ko) == co + ko:
		ko += 2
	ans += '***'
	s = co + ko
ans += b[s:]
print(ans)


a = int(input())
string = input()
first = []
last = []
sas = False
i = 1
while i < a:
	i += 1
	if not sas:
		if string[i - 2:i + 1] == 'ogo':
			first += [i - 2]
			sas = True
			i += 1
	elif string[i - 1:i + 1] == 'go':
		i += 1
	else:
		last += [i - 2]
		sas = False
if sas:
	last += [a - 1]
s = ''
counter = 0
n = 0
while counter < len(string):
	if counter not in first:
		s += string[counter]
		counter += 1
	else:
		s += '***'
		counter = last[n] + 1
		n += 1
print(s)


n = int(input())
strs = input()
c = 0
if len(strs) < 3:
	print(strs)
	c = 1
k = 'ogo'
z = 0
if c != 1:
	while True:
		while k in strs:
			k += 'go'
			z = 1
		if z == 1:
			k = k[:-2]
			z = 0
		strs = strs.replace(k, '***')
		if k == 'ogo':
			print(strs)
			break
		else:
			k = 'ogo'


n = int(input())
s = input()
i = 0
s2 = 'ogo' + 'go' * (n // 2)
while s2 != 'o':
	s = s.replace(s2, '***')
	s2 = s2[:-2]
print(s)


n = int(input())
s = input()
for i in range(50, -1, -1):
	cool_s = 'ogo' + i * 'go'
	while cool_s in s:
		s = s[:s.find(cool_s)] + '***' + s[s.find(cool_s) + len(cool_s):]
print(s)


n = int(input())
l = list(input())
ans = ''
i = 0
while i < n:
	if l[i] == 'o':
		j = i + 1
		while j < n - 1 and l[j] == 'g' and (l[j + 1] == 'o'):
			j += 2
		if j - i > 1:
			ans += '***'
			i = j
		else:
			ans += l[i]
			i += 1
	else:
		ans += l[i]
		i += 1
print(ans)


i = 0
res = ''
n = int(input())
st = input()
if len(st) < 3:
	print(st)
else:
	while i < len(st):
		ps = st[i:i + 3]
		if ps == 'ogo':
			i = i + 3
			j = i
			res = res + '***'
			while j < len(st):
				pa = st[j:j + 2]
				if pa == 'go':
					j = j + 2
					i = i + 2
				else:
					break
		else:
			res = res + st[i]
			i = i + 1
	print(res)


n = int(input())
s = input()
ans = ''
last_ind = 0
i = 0
while i < n:
	if s[i:i + 3] == 'ogo':
		i += 2
	else:
		i += 1
		if i - last_ind > 1:
			ans += '***'
		else:
			ans += s[last_ind:i]
		last_ind = i
print(ans)


n = int(input())
s = input()
save = ''
i = 0
ny = ''
while i < n:
	if save == '':
		if s[i:i + 3] == 'ogo':
			save = 'o'
			i += 2
		else:
			ny += s[i]
	elif s[i:i + 2] == 'go':
		i += 1
	else:
		save = ''
		ny += '***'
		i -= 1
	i += 1
if save != '':
	ny += '***'
print(ny)


n = int(input())
IN = input()
a = 'ogo' + 'go' * (n // 2)
while IN.find('ogo') != -1:
	while IN.find(a) != -1:
		IN = IN.replace(a, '***')
	a = a[:-2]
print(IN)


n = int(input())
s = input()
parazit = 'ogo'
endline = ''
end = -1
for i in range(len(s)):
	if i >= end:
		if s[i:i + 3] != parazit:
			endline += s[i]
		else:
			start = i + 3
			end = start + 2
			while 1:
				if s[start:end] == 'go':
					start += 2
					end += 2
				else:
					end = start
					break
			endline += '***'
print(endline)


input()
s = input()
l = s.find('ogo')
while l != -1:
	r = l + 3
	while s[r:r + 2] == 'go':
		r += 2
	s = s[:l] + '***' + s[r:]
	l = s.find('ogo')
print(s)


n = int(input())
s = list(input())
n = ''
buf = 0
i = 0
while i < len(s):
	if i + 3 < len(s) + 1 and s[i] == 'o' and (s[i:i + 3] == ['o', 'g', 'o']):
		n += '***'
		i += 3
	elif i + 2 < len(s) + 1 and s[i:i + 2] == ['g', 'o'] and (len(n) > 2) and (n[len(n) - 1] == '*'):
		i += 2
	else:
		n += s[i]
		i += 1
print(n)


n = int(input())
s = list(input())
for (i, j) in enumerate(s):
	if s[i:i + 3] == list('ogo'):
		to = i + 3
		num = 3
		x = i + num
		while s[i + num:i + num + 2] == list('go'):
			to += 2
			num += 2
		s[i:to] = list('***')
print(''.join(s))


input()
(X, i) = (input(), 0)
while i < len(X):
	Temp = X[i:i + 3]
	if Temp == 'ogo':
		while Temp == 'ogo':
			i += 2
			Temp = X[i:i + 3]
		print('***', end='')
	else:
		print(X[i], end='')
	i += 1


class CodeforcesTask729ASolution:

	def __init__(self):
		self.result = ''
		self.n = 0
		self.word = ''

	def read_input(self):
		self.n = int(input())
		self.word = input()

	def process_task(self):
		ogos = ['og' * (x + 1) + 'o' for x in range((self.n + 1) // 2)]
		ogos = ogos[::-1]
		for ogo in ogos:
			self.word = self.word.replace(ogo, '***')
		self.result = self.word

	def get_result(self):
		return self.result
Solution = CodeforcesTask729ASolution()
Solution.read_input()
Solution.process_task()
print(Solution.get_result())


input()
s = input()
flag = 0
ans = ''
while s:
	if not flag:
		if s.startswith('ogo'):
			flag = 1
			s = s[3:]
			ans += '***'
		else:
			ans += s[0]
			s = s[1:]
	elif s.startswith('go'):
		s = s[2:]
	else:
		flag = 0
print(ans)


n = int(input())
s = input()
mas = []
T = True
for i in s:
	mas.append(i)
for i in range(20):
	mas.append('0')
i = 0
while i <= len(mas) - 4:
	if mas[i] == 'o':
		if mas[i + 1] == 'g':
			if mas[i + 2] == 'o':
				mas[i] = '*'
				mas[i + 1] = '*'
				mas[i + 2] = '*'
				while T == True:
					if mas[i + 3] == 'g':
						if mas[i + 4] == 'o':
							del mas[i + 3]
							del mas[i + 3]
						else:
							T = False
					else:
						T = False
	i = i + 1
	T = True
for i in mas:
	if i != '0':
		print(i, end='')


n = input()
s = input()
for n in reversed(range(0, 100)):
	s = s.replace('ogo' + n * 'go', '***')
print(s)


import re
input()
find = re.compile('(ogo(go)*)')
s = input()
print(find.sub('***', s))


n = int(input())
s = input()
i = 0
f = ''
while i < n:
	c = 0
	if s[i:i + 3] == 'ogo':
		c = 3
		for j in range(i + 3, n, 2):
			if s[j:j + 2] == 'go':
				c += 2
			else:
				break
		i += c
		f += '***'
	else:
		f += s[i]
		i += 1
print(f)


n = int(input())
s = input()
st = s.find('ogo')
while st != -1:
	s = s[:st] + '***' + s[st + 3:]
	t = st
	st = st + 3
	while st + 2 <= len(s) and s[st:st + 2] == 'go':
		st += 2
	s = s[:t] + '***' + s[st:]
	st = s.find('ogo')
print(s)


(n, a) = (int(input()), input())
for i in range(n // 2, 0, -1):
	a = a.replace('og' * i + 'o', '***')
print(a)


import re
n = input()
s = input()
res = re.sub('ogo(go)*', '***', s)
print(res)


a = input()
a = input()
while True:
	print(a[:a.find('ogo')], end='')
	if a.find('ogo') != -1:
		print('***', end='')
		a = a[a.find('ogo') + 3:]
		while a[:2] == 'go':
			a = a[2:]
	else:
		try:
			print(a[-1])
		except:
			pass
		break


import math
import sys
input = sys.stdin.readline
n = int(input())
a = list(input())
cur = 0
idx = []
while cur <= n - 2:
	if a[cur] + a[cur + 1] + a[cur + 2] == 'ogo':
		idx.append(cur)
	cur += 1
ans = []
cur = 0
while cur < n:
	if cur in idx:
		p = idx.index(cur)
		q = p - 1
		if q == -1:
			cur += 2
			[ans.append('*') for _ in range(3)]
		elif idx[p] - idx[q] != 2:
			cur += 2
			[ans.append('*') for _ in range(3)]
		else:
			cur += 2
	else:
		if cur - 2 not in idx:
			ans.append(a[cur])
		cur += 1
print(''.join(ans))


import re
n = input()
print(re.subn('ogo(go)*', '***', input())[0])


res = ''
n = int(input())
s = input()
i = 0
while i < n:
	if s[i] not in ('o', 'g'):
		res += s[i]
		i += 1
	elif s[i:i + 3] == 'ogo':
		i += 3
		while s[i:i + 2] == 'go':
			i += 2
		res += '***'
	else:
		res += s[i]
		i += 1
print(res)