Yeongseon is in a good mood, so she wants to send Hyobin exactly S smile emoticons.
One emoticon is already typed on the screen. Yeongseon wants to reach S emoticons on the screen using only the following three operations.
- Copy every emoticon on the screen into the clipboard.
- Paste every emoticon in the clipboard onto the screen.
- Delete one emoticon from the screen.
Each operation takes 1 second. A copy erases whatever the clipboard held before. Pasting is impossible while the clipboard is empty, and copying only part of the emoticons on the screen is impossible. Deleting only part of the emoticons in the clipboard is impossible as well. A paste adds the number of emoticons in the clipboard to the number on the screen.
Write a program that finds the minimum time Yeongseon needs to put S emoticons on the screen.