# coding=utf8
# the above tag defines encoding for this document and is for Python 2.x compatibility

import re

pattern = r"(?=(?:.{4})*$)"
s = "01234567891234oooooooooooooooo321"
print(re.sub(pattern, "#", s))
