#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, bi, res = 0;
  char *input = new char[4000001];
  char last_move;
  bool same_move = false;
  cin >> n;
  cin >> input;
  for (int i = 0; input[i] != '\0'; ++i) {
    bi = i % n;
    if (bi > 0 && bi < n - 3) continue;
    if (bi == n - 3) {
      last_move = input[i];
      same_move = true;
    } else if (bi > n - 3) {
      if (last_move != input[i]) {
        same_move = false;
      }
    } else {
      if (same_move) {
        res++;
      }
    }
  }
  cout << res;
  return 0;
}
