#!/usr/bin/env python

"""
Replaces stretches of characters annotated O longer than 3 by just the first
character.
"""

import sys

from itertools import chain

instretch = False

for line in chain(sys.stdin, ['']):
    line = line.rstrip()
    if instretch:
        if line.endswith('O'):
            stretch.append(line)
        else:
            instretch = False
            if len(stretch) < 4:
                for sline in stretch:
                    print sline
            else:
                print stretch[0] 
            print line
    else:
        if line.endswith('O'):
            instretch = True
            stretch = [line]
        else:
            print line
