longest repetition solution