import os b=t="" s=os.read(0,999) for c in s: i=b.rfind(c) if i>=0:t+=`len(b)-1-i` else:t+=c if c.isalpha():b+=c;b=b[-10:] print t