Peterson love learn new language favorite hobby make new one Language set word word sequence lowercase Latin lettersPeterson make new language morning it difficult task store language Peterson invent new data structure store language call broom Broom root tree edge mark letter Initially broom represent vertex root broom when Peterson wants add new word language stand root process letter new word Consider Peterson stand vertex u if edge u mark current letter Peterson go edge Otherwise Peterson add new edge u new vertex v mark current letter go new edge Size broom number vertex itin evening work day Peterson can not understand language morning it difficult bored Peterson try simple Simplification language process erase letter word language Formally Peterson take positive integer p erase pth letter word language have length p Letters word index start 1 Peterson consider simplification change word ie word length p Peterson try language simple possible wants choose p size broom simplify language small possiblepeterson pretty annoyed task ask help write program find small possible size broom integer p