#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string a;
  cin >> a;
  int p = 0;
  int q = 0;
  int drinks = 0;
  int ff = 1;
  for (int i = 1; i < a.size(); i++) {
    if (i % n != 0 && i > (ff * n) - 4) {
      if (a[i] == 'a')
        p++;
      else
        q++;
    } else if (i % n == 0) {
      if (p == 3 || q == 3) drinks++;
      p = 0;
      q = 0;
      ff++;
    }
  }
  cout << drinks;
}
