#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a = 0, b = 0;
  string str;
  cin >> str;
  int ans = 0;
  for (int j = 0; j < str.length(); j++) {
    if (j % n == 0) {
      if (a >= 3 || b >= 3) ans++;
    }
    if (str[j] == 'a') {
      a++;
      b = 0;
    } else {
      b++;
      a = 0;
    }
  }
  cout << ans << endl;
  return 0;
}
