QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 32 MB Total points: 100 Hackable ✓

#11865. Template

统计

Byteasar wants to put a rather long pattern on his house. In order to do this, he has to prepare an appropriate template with letters cut off first. He is going to put the pattern on the wall by putting the pattern on the wall in the appropriate place and painting over it. This way he can "print" all the letters that are on the template at one time (it is not possible to "print" only some of them). It is, however, possible, to paint some letters on the wall several times, as a result of different applications of the template. The letters on the template are adjacent (there are no spaces on it). Of course, it is possible to prepare a template with the whole pattern on it. But Byteasar would like to minimize the cost, so he wants to make a template as short as possible.

Write a programme that:

  • reads from the standard input the pattern Byteasar wants to put on his house,
  • determines the minimal length of the template needed to do it,
  • writes the result to the standard output.

Input

In the first and only line of the standard input there is one word. It is the pattern Byteasar wants painted on his house. It consists of no more than 500,000 and no less than 1 lower-case (non-capital) letters of the English alphabet.

Output

In the first and only line of the standard output one integer should be written - the minimal number of letters in the template.

Example

Input

ababbababbabababbabababbababbaba

Output

8
problem_11865_1.gif
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.