#include <stdio.h>

main()
{
	int n, i, ans = 0;
	scanf("%d", &n);
	char s[n+1];
	for (i = 0; i < n; ++i) {
		scanf("%c", &s[i]);
		if (i >= 2 && s[i] == 'C')
			if (s[i-2] == 'A' && s[i-1] == 'B')
				++ans;
	}
	printf("%d\n", ans);
}