#include <bits/stdc++.h>
using namespace std;
bool bit(int n, int i) { return (n >> i) & 1; }
int ceil(int a, int b) {
  if (a % b == 0)
    return a / b;
  else
    return a / b + 1;
}
int faltu;
const int mod = 1e9 + 7;
const long long MAX = 4e18;
const long long MIN = -MAX;
const int imax = 1e9 + 100;
const int maxn = 1e5 + 10;
pair<int, int> dp[maxn];
int ct[maxn][2];
int c_ques[maxn];
int cost[maxn];
bool pos[maxn];
int stree[maxn * 4];
int m;
void build(int i, int j, int sidx) {
  if (i == j) {
    if (i <= m and pos[i]) {
      stree[sidx] = cost[i];
    } else {
      stree[sidx] = imax;
    }
    return;
  }
  build(i, ((i + j) >> 1), sidx * 2);
  build(((i + j) >> 1) + 1, j, sidx * 2 + 1);
  stree[sidx] = min(stree[sidx * 2], stree[sidx * 2 + 1]);
}
int query(int i, int j, int sidx, int ql, int qr) {
  if (ql > qr) {
    return imax;
  } else if (ql > j or qr < i) {
    return imax;
  } else if (ql <= i and j <= qr) {
    return stree[sidx];
  } else {
    return min(query(i, ((i + j) >> 1), sidx * 2, ql, qr),
               query(((i + j) >> 1) + 1, j, sidx * 2 + 1, ql, qr));
  }
}
void update(int i, int j, int sidx, int idx, int val) {
  if (i > idx or j < idx) {
    return;
  } else if (i == j and i == idx) {
    stree[sidx] = val;
    return;
  }
  update(i, ((i + j) >> 1), sidx * 2, idx, val);
  update(((i + j) >> 1) + 1, j, sidx * 2 + 1, idx, val);
  stree[sidx] = min(stree[sidx * 2], stree[sidx * 2 + 1]);
}
void preprocess(string& s, int m) {
  int n = s.length() - 1;
  for (int i = n; i >= 1; i--) {
    if (s[i] == 'a' or s[i] == '?') {
      ct[i][0] = ct[i + 2][0] + 1;
    }
    if (s[i] == 'b' or s[i] == '?') {
      ct[i][1] = ct[i + 2][1] + 1;
    }
    c_ques[i] = c_ques[i + 1] + (s[i] == '?' ? 1 : 0);
    if (ct[i][0] >= ceil(m, 2) and ct[i + 1][1] >= m / 2) {
      pos[i] = true;
      cost[i] = c_ques[i] - c_ques[i + m];
    } else {
      cost[i] = imax;
    }
  }
}
pair<int, int> operator+(const pair<int, int> a, const pair<int, int> b) {
  return {a.first + b.first, a.second + b.second};
}
int find(int val, int j) {
  int lo = 0, hi = j, mid, ans = j;
  while (lo <= hi) {
    mid = (lo + hi) >> 1;
    if (dp[mid].first < val) {
      lo = mid + 1;
    } else {
      ans = mid;
      hi = mid - 1;
    }
  }
  return ans;
}
pair<int, int> max(pair<int, int> a, pair<int, int> b) {
  if (a.first > b.first) return a;
  if (a.first == b.first and a.second < b.second) return a;
  return b;
}
int main() {
  time_t t1, t2;
  t1 = clock();
  int n;
  string s;
  cin >> n >> s >> m;
  s.insert(0, ".");
  preprocess(s, m);
  for (int i = 1; i < m; i++) {
    dp[i] = {0, 0};
  }
  build(1, n, 1);
  for (int i = m; i <= n; i++) {
    dp[i] = dp[i - 1];
    int idx = i - m + 1;
    int min_cost = cost[idx] + dp[idx - 1].second;
    if (pos[idx] and dp[idx - 1].first == dp[i].first) {
      dp[i] = {dp[i].first + 1, min_cost};
    } else if (pos[idx] and dp[idx - 1].first + 1 == dp[i].first and
               min_cost < dp[i].second) {
      dp[i].second = min_cost;
    }
    if (pos[idx]) {
      dp[i].first = dp[idx - 1].first + 1;
      dp[i].second = dp[idx - 1].second + cost[idx];
    }
    dp[i] = max(dp[i - 1], dp[i]);
    if (pos[i + 1]) {
      update(1, n, 1, i + 1, dp[i].second + cost[i + 1]);
    }
  }
  cout << dp[n].second << endl;
  t2 = clock();
  cerr << "time taken: " << t2 - t1 << endl;
  return 0;
}

### Prompt

Please provide a cpp coded solution to the problem described below:

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 t1 = si, t2 = si + 1, ..., tm = si + 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 ≤ 105) — 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 ≤ 105) — 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.

Examples

Input

5
bb?a?
1


Output

2


Input

9
ab??ab???
3


Output

2

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.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
bool bit(int n, int i) { return (n >> i) & 1; }
int ceil(int a, int b) {
  if (a % b == 0)
    return a / b;
  else
    return a / b + 1;
}
int faltu;
const int mod = 1e9 + 7;
const long long MAX = 4e18;
const long long MIN = -MAX;
const int imax = 1e9 + 100;
const int maxn = 1e5 + 10;
pair<int, int> dp[maxn];
int ct[maxn][2];
int c_ques[maxn];
int cost[maxn];
bool pos[maxn];
int stree[maxn * 4];
int m;
void build(int i, int j, int sidx) {
  if (i == j) {
    if (i <= m and pos[i]) {
      stree[sidx] = cost[i];
    } else {
      stree[sidx] = imax;
    }
    return;
  }
  build(i, ((i + j) >> 1), sidx * 2);
  build(((i + j) >> 1) + 1, j, sidx * 2 + 1);
  stree[sidx] = min(stree[sidx * 2], stree[sidx * 2 + 1]);
}
int query(int i, int j, int sidx, int ql, int qr) {
  if (ql > qr) {
    return imax;
  } else if (ql > j or qr < i) {
    return imax;
  } else if (ql <= i and j <= qr) {
    return stree[sidx];
  } else {
    return min(query(i, ((i + j) >> 1), sidx * 2, ql, qr),
               query(((i + j) >> 1) + 1, j, sidx * 2 + 1, ql, qr));
  }
}
void update(int i, int j, int sidx, int idx, int val) {
  if (i > idx or j < idx) {
    return;
  } else if (i == j and i == idx) {
    stree[sidx] = val;
    return;
  }
  update(i, ((i + j) >> 1), sidx * 2, idx, val);
  update(((i + j) >> 1) + 1, j, sidx * 2 + 1, idx, val);
  stree[sidx] = min(stree[sidx * 2], stree[sidx * 2 + 1]);
}
void preprocess(string& s, int m) {
  int n = s.length() - 1;
  for (int i = n; i >= 1; i--) {
    if (s[i] == 'a' or s[i] == '?') {
      ct[i][0] = ct[i + 2][0] + 1;
    }
    if (s[i] == 'b' or s[i] == '?') {
      ct[i][1] = ct[i + 2][1] + 1;
    }
    c_ques[i] = c_ques[i + 1] + (s[i] == '?' ? 1 : 0);
    if (ct[i][0] >= ceil(m, 2) and ct[i + 1][1] >= m / 2) {
      pos[i] = true;
      cost[i] = c_ques[i] - c_ques[i + m];
    } else {
      cost[i] = imax;
    }
  }
}
pair<int, int> operator+(const pair<int, int> a, const pair<int, int> b) {
  return {a.first + b.first, a.second + b.second};
}
int find(int val, int j) {
  int lo = 0, hi = j, mid, ans = j;
  while (lo <= hi) {
    mid = (lo + hi) >> 1;
    if (dp[mid].first < val) {
      lo = mid + 1;
    } else {
      ans = mid;
      hi = mid - 1;
    }
  }
  return ans;
}
pair<int, int> max(pair<int, int> a, pair<int, int> b) {
  if (a.first > b.first) return a;
  if (a.first == b.first and a.second < b.second) return a;
  return b;
}
int main() {
  time_t t1, t2;
  t1 = clock();
  int n;
  string s;
  cin >> n >> s >> m;
  s.insert(0, ".");
  preprocess(s, m);
  for (int i = 1; i < m; i++) {
    dp[i] = {0, 0};
  }
  build(1, n, 1);
  for (int i = m; i <= n; i++) {
    dp[i] = dp[i - 1];
    int idx = i - m + 1;
    int min_cost = cost[idx] + dp[idx - 1].second;
    if (pos[idx] and dp[idx - 1].first == dp[i].first) {
      dp[i] = {dp[i].first + 1, min_cost};
    } else if (pos[idx] and dp[idx - 1].first + 1 == dp[i].first and
               min_cost < dp[i].second) {
      dp[i].second = min_cost;
    }
    if (pos[idx]) {
      dp[i].first = dp[idx - 1].first + 1;
      dp[i].second = dp[idx - 1].second + cost[idx];
    }
    dp[i] = max(dp[i - 1], dp[i]);
    if (pos[i + 1]) {
      update(1, n, 1, i + 1, dp[i].second + cost[i + 1]);
    }
  }
  cout << dp[n].second << endl;
  t2 = clock();
  cerr << "time taken: " << t2 - t1 << endl;
  return 0;
}

```