#include <bits/stdc++.h>
using namespace std;
int al[2000], ar[2000], bl[2000], br[2000];
int main() {
  ios::sync_with_stdio(0);
  int n;
  string s;
  cin >> n >> s;
  int palen = 0, pblen = 0;
  int ans = 0;
  for (int i = 0; i < ((int)s.size()); i++) {
    if (i % n == 0) {
      int mv = max(palen, pblen);
      if (mv >= 3) ++ans;
    }
    if (s[i] == 'a') {
      palen++;
      pblen = 0;
    } else {
      pblen++;
      palen = 0;
    }
  }
  cout << ans << "\n";
  return 0;
}
