The Longest Force Protecting the Republic of Korea
InterviewTime limit1sMemory limit1024 MB
Given a digit string, split it into the fewest pieces where each piece is a number from 1 to 641 without leading zeros.
- Level
Easy3 of 10
- Topics
- Dynamic programming, String
- Solved
- No attempts yet
Problem
The motto of the Republic of Korea Air Force is "The Highest Force Protecting the Republic of Korea." However, Air Force service lasts year and months, the longest among active-duty soldiers. Air Force soldiers therefore joke bitterly that they are "The Longest Force Protecting the Republic of Korea."
Today, soldiers in Dohun's unit were trading this joke, and they decided to make a discharge paper that expresses their hope to get out of the military. A discharge paper is a long sheet on which each soldier writes the number of remaining service days in a single line with no spaces. For example, if three soldiers have , , and days left and write them in that order, the paper shows . The maximum service length in the Air Force is days, so every soldier who wrote a remaining count wrote a number from to inclusive, and no leading zeros were added.
While looking at the paper, Dohun wondered how many soldiers wrote their own remaining service days on it. The paper alone does not reveal the exact count. Under the condition that each soldier wrote a number from to , find the minimum possible number of soldiers who wrote the paper.
Input
The first line contains , the number of digits of the number written on the discharge paper.
The second line contains the integer , a string of length representing the number written on the discharge paper.
It is guaranteed that can be the number written on a discharge paper.
Output
On the first line, print the minimum number of soldiers who wrote the discharge paper.
Constraints
- All input values are integers.