Codeforces Round 450 (Div. 2)
E
Maximum Questions
Codeforces
2100
原题
← D→
翻译中…

Vasya wrote down two strings $*s*$ of length $*n*$ and $*t*$ of length $*m*$ consisting of small English letters 'a' and 'b'. What is more, he knows that string $*t*$ has a form "abab...", namely there are letters 'a' on odd positions and letters 'b' on even positions.

翻译中…

Suddenly in the morning, Vasya found that somebody spoiled his string. Some letters of the string $*s*$ were replaced by character '?'.

翻译中…

Let's call a sequence of positions $*i*, *i* + 1, ..., *i* + *m* - 1$ as occurrence of string $*t*$ in $*s*$, if $1 ≤ *i* ≤ *n* - *m* + 1$ and $*t*_{1} = *s*_{*i*}, *t*_{2} = *s*_{*i* + 1}, ..., *t*_{*m*} = *s*_{*i* + *m* - 1}$.

翻译中…

The boy defines the beauty of the string $*s*$ as maximum number of disjoint occurrences of string $*t*$ in $*s*$. Vasya can replace some letters '?' with 'a' or 'b' (letters on different positions can be replaced with different letter). Vasya wants to make some replacements in such a way that beauty of string $*s*$ is maximum possible. From all such options, he wants to choose one with the minimum number of replacements. Find the number of replacements he should make.

翻译中…

Input

翻译中…

The first line contains a single integer $*n*$ ($1 ≤ *n* ≤ 10^{5}$) — the length of $*s*$.

翻译中…

The second line contains the string $*s*$ of length $*n*$. It contains small English letters 'a', 'b' and characters '?' only.

翻译中…

The third line contains a single integer $*m*$ ($1 ≤ *m* ≤ 10^{5}$) — the length of $*t*$. The string $*t*$ contains letters 'a' on odd positions and 'b' on even positions.

翻译中…

Output

翻译中…

Print the only integer — the minimum number of replacements Vasya has to perform to make the beauty of string $*s*$ the maximum possible.

翻译中…

Note

翻译中…

In the first sample string $*t*$ has a form 'a'. The only optimal option is to replace all characters '?' by 'a'.

翻译中…

In the second sample using two replacements we can make string equal to "aba?aba??". It is impossible to get more than two occurrences.

翻译中…

样例

Input #1
5
bb?a?
1
Output #1
2
InputCopy OutputCopy
Input #2
9
ab??ab???
3
Output #2
2
InputCopy OutputCopy
题目信息
题号
900E
时间限制
2 s
内存限制
256 MB
标签
数据结构
动态规划
字符串

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。