Streaming Services
면접 대비시간 제한2초메모리 제한512 MB
각 날짜에 어느 스트리밍 서비스가 에피소드를 공개하는지 나타내는 문자열이 주어질 때, 길이 K인 구독을 사서 매일 공개를 시청할 수 있도록 하면서 구독 구매 횟수를 최소화한다.
문제
Last year, you finally went ahead and became a cord-cutter, cancelling your TV subscription to avoid all the annoying ads. This was a relief. Suddenly, you could watch TV whenever you wanted, rather than when the TV channels dictated it. Of course, this new-found happiness was short-lived. The streaming services quickly started adapting the old "one episode a week" paradigm that the old TV channels were based on, and suddenly the conversations during lunch at work started revolving around the episodes released on the previous day on the streaming services.
A streaming service works like this. At some specific days, a service will release exactly one new episode of a TV show. Every day, you need to watch an episode that was released during this day, so you can join in on the lunch conversations the day after.
Since your favourite streaming service may sometimes not release an episode, you plan to use two streaming services instead. At any given day, you can buy a subscription of a service that you do not currently subscribe to. A subscription runs for days, and during each of these days, you can watch episodes on the streaming service you just bought a subscription for. Even if you have an active subscription for a service, you may purchase a subscription for the other service.
Given the dates when each service releases a new episode for the following days, determine the total number of subscription periods you need to buy to each day have an active subscription for a service that releases a new episode.
입력
The first line contains , the number of days you have the release schedule for, and , the number of days each subscription runs for (). The next line contains a string of characters, consisting only of characters 1, 2 or B.
The 'th character describes whether a new episode is released on the first service (1), second service (2), or both services (B) on day .
출력
Output a single integer; the number of times you need to purchase a streaming service subscription to watch a newly released episode each day.