|When returning from vacation, you have to delete some unwanted email messages in your inbox, like spam or other unimportant messages. Your inbox consists of several pages that each contain the same number of messages (except possibly the last page). Each message has two corresponding buttons that allow you to: |
- add the message to the current selection
- remove the message from the current selection
In addition, each page has three buttons with the following functions:
- select all messages on the current page
- delete all selected messages on the current page
- advance to the next page of messages (unless you're already on the last page)
Selections do not extend across pages, and advancing to the next page deselects everything that is currently selected. Also, deleting messages will not cause later messages in the inbox to scroll up to the current page.
For example if you have four email messages on one page and you would like to delete the second one, you could select it and then click on delete for a total of two clicks. An alternative is to select all messages, then deselect all other messages except the second, and then click delete, for a total of five clicks.
Naturally, you would like to clean up your inbox with as few clicks as possible. Furthermore, you are allowed to choose the number of emails to display per page. If you decide to display K messages per page, the first K messages will be on the first page, the next K messages will be on the second one, and so on. Obviously, the last page might contain less than K messages. Note that you need to check all pages of messages, even if they do not contain any messages that must be deleted.
You will be given a String messages containing a description of email messages in the order they appear in your inbox. The 'D' character denotes a message that should be deleted, while a '.' character denotes an email that should be kept. You will also be given two ints, low and high, denoting the inclusive lower and upper bounds of the number of messages on each page. You should choose how many emails to display per page such that the number of clicks needed is minimal, and then return the number of clicks.
|-||messages will contain between 1 and 50 characters, inclusive.|
|-||Each character of messages will be either 'D' or '.'.|
|-||low will be between 1 and the number of characters in messages, inclusive.|
|-||high will be between low and the number of characters in messages, inclusive.|