Dolbear's Law
InterviewTime limit1sMemory limit1024 MB
Given a per-second record of chirps, find the fewest crickets that could explain it when each cricket chirps at a fixed period between a start and a stop.
- Level
Medium4 of 10
- Topics
- Brute force, Implementation, Math
- Solved
- No attempts yet
Problem
Dolbear's law describes the relationship between the chirping of crickets and the surrounding temperature.
- : temperature in degrees Fahrenheit, : number of times a cricket chirps in one minute
Yechan wants to check whether Dolbear's law is true by counting how many times crickets chirp over seconds. However, the chirps of several crickets overlap, so he cannot count them properly and gives up on the proof.
Instead, Yechan records the chirps at 1-second intervals for seconds and wants to find the minimum number of crickets that are chirping.
Every cricket follows these rules.
- Each cricket starts chirping at some moment, then chirps once each time a period passes.
- The period is a positive integer chosen freely, and every cricket has the same period.
- Each cricket stops chirping at some moment and does not chirp after that.
Help Yechan find the minimum number of crickets that are chirping.
Input
The first line contains the measurement time .
The second line contains Yechan's record as a string of length , made only of . and #. A . means no cricket chirped at that second, and a # means at least one cricket chirped.
Output
Print the minimum number of crickets that are chirping on the first line.
Constraints
- The input string contains only
.and#.